The annotation javax.ejb.Startup (@Startup) is used to mark an EJB so to make the EJB can be brought up during the application is running up. However, if you have multiple automatic loaded EJBs, then a question comes to you, how to make sure there loading sequence? Now, in EJB 3.1, you may use the annotation javax.ejb.DependsOn (@DependsOn) to achieve this. Please see the following example:

@Singleton
public class PrimaryBean { ... }

SecondaryBean depends on PrimaryBean:

@Singleton
@DependsOn("PrimaryBean")
public class SecondaryBean { ... }

If there is a third been needed to be automatically loaded, and you want the third been will be loaded after PrimaryBean and SecondaryBean have been loaded, so you need to:

@Singleton
@DependsOn("PrimaryBean", "SecondaryBean")
public class ThirdBean { ... }

In the case above, EJBs will be loaded in the order: 1. PrimaryBean; 2. SecondaryBean; 3. ThirdBean. If you just removed the dependence from SecondaryBean, the container will load either PrimaryBean or SecondaryBean firstly, then the ThirdBean.
 
Reference:
1. Initializing Singleton Session Beans (The Java EE 6 Tutorial) https://docs.oracle.com/cd/E19798-01/821-1841/gippq/index.html

EJB 3.1 @Startup @Singleton sequence的更多相关文章

  1. EJBTimer 使用EJB提供的定时器

    一.说明 EJB提供的定时器有两种,自动定时器和自定义定时器,自动定时器设置使用简单但是扩展较为麻烦,自定义定时器有较好的扩展性. 下面的例子中是把两中方式放到了一个测试类中. 二.示例 import ...

  2. 单件模式Singleton来控制窗体被重复或多次打开

    本文转载:http://blog.csdn.net/a0700746/article/details/4473796 一般在百度搜一下,会出来一下内容,看来很好用.Singleton很方便的一个用处就 ...

  3. 转载 单例(Singleton)模式)的误区

    在创建型模式中,单例(Singleton)模式和原型(Prototype)模式相对来说其用意更为简单明了.单例(Singleton)模式确保某类只有一个实例,且自行实例化并向整个系统提供这个实例:原型 ...

  4. 设计模式之Singleton(单态)(转)

    定义: Singleton模式主要作用是保证在Java应用程序中,一个类Class只有一个实例存在. 在很多操作中,比如建立目录 数据库连接都需要这样的单线程操作. 还有, singleton能够被状 ...

  5. Java设计模式(2)单态模式(Singleton模式)

    定义:Singleton模式主要作用是保证在Java应用程序中,一个类Class只有一个实例存在. 在很多操作中,比如建立目录 数据库连接都需要这样的单线程操作. 还有,singleton能够被状态化 ...

  6. 单例模式——Java EE设计模式解析与应用

    单例模式 目录: 一.何为单例 二.使用Java EE实现单例模式 三.使用场景 一.何为单例 确保一个类只有一个实例,并且提供了实例的一个全局访问点 1.1 单例模式类图               ...

  7. 单例模式——java设计模式

    单例模式 目录: 一.何为单例 二.使用Java EE实现单例模式 三.使用场景 一.何为单例 确保一个类只有一个实例,并且提供了实例的一个全局访问点 1.1 单例模式类图               ...

  8. RAC的QA

    RAC: Frequently Asked Questions [ID 220970.1]   修改时间 13-JAN-2011     类型 FAQ     状态 PUBLISHED   Appli ...

  9. MES: ESB

    ESB定义了消息的收发和收发池,对于各种通讯方式定义了收发API,在收到信息后由eventBus来发布消息 ISender: public abstract interface ISender { p ...

随机推荐

  1. Tensorflow样例代码分析cifar10

    github地址:https://github.com/tensorflow/models.git 本文分析tutorial/image/cifar10教程项目的cifar10_input.py代码. ...

  2. Struts2入门介绍(二)

    一.Struts执行过程的分析. 当我们在浏览器中输入了网址http://127.0.0.1:8080/Struts2_01/hello.action的时候,Struts2做了如下过程: 1.Stru ...

  3. python: local variable 'xxx' referenced before assignment

    问题发现 xxx = 23 def PrintFileName(strFileName): if xxx == 23: print strFileName xxx = 24 PrintFileName ...

  4. python中文分词工具——结巴分词

    传送门: http://www.iteye.com/news/26184-jieba

  5. POj2387——Til the Cows Come Home——————【最短路】

    A - Til the Cows Come Home Time Limit:1000MS     Memory Limit:65536KB     64bit IO Format:%I64d & ...

  6. python-入门教程(-)

    # hello worldprint("hello world") # 变量msg = "使用变量"print(msg) # 字符串大小写变换(仅针对英文)na ...

  7. bzoj 2164: 采矿

    Description 浩浩荡荡的cg大军发现了一座矿产资源极其丰富的城市,他们打算在这座城市实施新的采矿战略.这个城市可以看成一棵有n个节点的有根树,我们把每个节点用1到n的整数编号.为了方便起见, ...

  8. Ms SQL Server 游标嵌套 初始化数据

    --TRUNCATE TABLE TAB_ROLE_FUNC; --SELECT * FROM TAB_ROLE_FUNC; ), ; --外层游标 DECLARE CURSOR_ROLE CURSO ...

  9. 原创:微信小程序亲测体验,公众号入口曝光!

    扫描即可体验知乐微信小程序,并且看到入口 你可以在这里看到相应的小程序:微信小程序商店 发现内有历史列表入口 真实小程序 搜索 操作栏 放置到桌面示意图必须搜索全称,才可以搜索到小程序 推荐给朋友,可 ...

  10. No.2一步步学习vuejs 实例demo篇

    简单应用Vue.js 的核心是一个允许采用简洁的模板语法来声明式的将数据渲染进 DOM 的系统: <div id="app"> {{ message }} </d ...