ejb3.0 学习笔记




1 A session bean or a message-driven bean can be designed with bean-managed transaction demarcation
or with container-managed transaction demarcation. (But it cannot be both at the same time.)


2 Enterprise JavaBeans defines the following values for the TransactionAttribute metadata annotation:
• MANDATORY
• REQUIRED
• REQUIRES_NEW
• SUPPORTS
• NOT_SUPPORTED
• NEVER


supports : 如果上下文有transactionContext,就需要事务(效果和required一样),如果上下文没有,就不需要事务。(和not_supported一样)

MANDATORY: 是说如果调用上下文没有开启事务,就抛出一个异常,强制需要事务。

never: 如果上下文有开启事务,就抛出异常,表示强制不需要事务,刚好和mandatory相反。


3 写ejb的约束

An enterprise bean must not use read/write static fields. Using read-only static fields is
allowed. Therefore, it is recommended that all static fields in the enterprise bean class be
declared as final.  不要使用可读写的静态变量,如果要用的,使用final的标记。


An enterprise bean must not use thread synchronization primitives to synchronize execution of
multiple instances.

An enterprise bean must not use the AWT functionality display, or to input information from a keyboard.

An enterprise bean must not use the java.io package to attempt to access files and directories
in the file system.

An enterprise bean must not attempt to listen on a socket, accept connections on a socket, or
use a socket for multicast.不要使用server端的socket

The enterprise bean must not attempt to query a class to obtain information about the declared
members that are not otherwise accessible to the enterprise bean because of the security rules
of the Java language. The enterprise bean must not attempt to use the Reflection API to access
information that the security rules of the Java programming language make unavailable.不要使用reflection

The enterprise bean must not attempt to create a class loader; obtain the current class loader;
set the context class loader; set security manager; create a new security manager; stop the
JVM; or change the input, output, and error streams.不要去创建classloader或者获取classloader

The enterprise bean must not attempt to manage threads. The enterprise bean must not attempt
to start, stop, suspend, or resume a thread, or to change a thread’s priority or name. The enterprise
bean must not attempt to manage thread groups.不要去管理线程。
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值