Client can NOT call EJB direct, but through mediator
JMS in case of MDB(Message Driven Bean)
Container provides class implementing bean's interface: component interface & home interface
Instance of class implementing component interface is called EJBObject
client call EJB through two player: EJBObject & container
Things to remember - Inside a Bean
-
Do not directly read/write File Descriptor
-
Never try to obstain security policy of source code
-
Never use object substitute or subclass feature of java serializable protocol
-
Never pass this as parametor or return
-
Do not implement Bean as Server-like activity e.g. listener, multicasting on a socket
-
Never create/set/access classloader
-
Never set/create security manager
-
Never try to stop JVM
-
Never try to change input/output , error stream
-
Never try to set factory that is used by Server socket, and stream handle factory that is used by URL
-
Never
-
start, stop, resume a thread
-
change priority of a thread
-
change name of a thread
Same Bean can not define two env entries with same name
Different Bean can defined same env entries with same name, as when they access from bean it get its own variable
EJB communicate with container through SessionContext & SessionBean Interface
Home interface has create() and remove() method, create() needs to be defined, but remove() is inherited from parent
Create method in EJB
|
StateFul |
StateLess |
declare |
mandatory, no argument method |
at least one create() is mandatory, e.g.
createABC(...)
createBBB(...)
|
Bean instance creation |
create a new bean |
get bean from pooling |
Common property |
argument must be serializable, primitive |
argument must be serializable,primitive |
Remove method in EJB
|
Entity |
StateFul |
StateLess |
1. Remove(PrimaryKey)
2. Remove(Handle)
|
1 |
2. will remove instance |
2. no effect, will go back to pool
|
Common |
|
Contaner event, client can not call |
Contaner event, client can not call |
There is exactly one Object for each Session Bean Type, Multi EJBObject
e.g. 100 clients have 1 HomeInterface, but 100 EJbObject
method starting with ejbMethodA...() is container callback method
method can not throw RunTimeException(...)
isdential() method of EJBObject
-
stateful bean never been true
-
stateless bean return true, if referenced the client's handled by the same homeInterface
-
EjbObject are compared by isIdentical(), NOT equals()
EJBObject's remove() doesnt have argument, remove itself
HomeInterface's remove(...) has argument, as it needs argument to determine which one to remove
HomeLocalInterface does NOT have method for Handler & metaDate( in save JVM, information of method can be abtained from reflection)
Local HomeInterface doesn't have remove(handler), remove can be done directly call the LocalEJBOBject to remove itself
Remove sessionbean client can remove via RemoteHomeInterface & remote EJBObject
LocalHomeInterface can NOT be passed to remove call
In Bean method, dont declare throw RemoteException
setEntityContext and setSessionContext are used to setup sessionBean to interact with container
For stateful bean, when user call create(), createABC() in home Interface, EJB container will call ejbCreate() or ejbCreateABC() defined in session Bean respectively
EntityContext & SessionContext
-
One difference is that the entityContext has getPrimaryKey()
-
setSessionContext() can call two method of container: get Home Interface, and JNDI access
-
following method ejbCreate().
remove method call for statelss bean is ignored
Container will not passivate if session is in Transaction
remove is not call under:
-
time out in passivate state
-
bean throw exception
-
server crashes
Entity Bean
-
If can not find single entity, throw ObjectNotFoundException
-
If can not find group entity, return empty collection
For CMP, don't need write find method
For BMP, each findXXX method in Home Interface, must have a match ejbFindXXX in Bean Class
Home Interface can implement business logic which is not entity related
for each method, you are required to write ejbHomeXXX method in Bean
Each Bean Type has its own pool
Entity bean can only use ONLY CMT demartation, can NEVER use getUserTransaction method
Only difference between EntityContext & SessionContext is getPrimaryKey() defined in EntityContext
EJB Remote interface is closely related to RMI-IIOP protocol
Parameter passed into EJB method must be RMI-IIOP conpatible
EJB Object - Container generated Remote Interface Implementation
Local Object - Container generated local interface implementation
Home Object - Container generated home interface implementation
Loca home Object - Container generated local home interface implementation
System exception - Container will process it
Application excepton - should throw back to client/ the only exception for remote EJB thrown back is REMOTE or its subClass
EJB bean is called via EJB Object, thus if your bean calls another bean, you must pass reference to your bean's EJB Object rather than reference of your bean; Just like another client, everything must go through EJB Object
When bean is passivated, it might hold reference to container-implemented object, the following object will be passivated as well
-
EJB Object reference
-
Home Object reference
-
EJB context reference
-
JNDI naming context
Stateless can define a few overloaded ejbCreate(...)
Stateful can only define one empty ejbCreate()
The biggest difference between the stateful session bean and the other bean types is that stateful session beans don't use
instance pooling.
相关推荐
SCBCD notes from JiaFan useful for test
很好的学习 SUN SCBCD 考试教程
SCBCD-091资料 曾经考试用过的资料,为了以后的某天回顾 不建议下载
SCBCD Exam Study Kit Java Business Component Developer Certification for EJB.Jun.2005 sun认证材料
SCBCD summary from questions look into it before test
SCBCD simulator, includes about 300 questions and explanation
310-091 SCBCD5 sun java
SCBCD.5.Study.Guide SUN EJB3.0认证考试资料
SUN公司2009年最新SCJP考试认证大纲,详解考试题型及内容
包含了SCJP5.0\SCWCD1.4\SCBCD1.3\SCBCD5.0\SCDJWS1.4\SCDJWS5.0\SCEA5.0\IBM Test 255\IBM Test 257\IBM Test 287\IBM Test 733等众多英文版参考资料,考试必备,内含源码,本人特别贡献出来给大家,绝对物超所值!
SCBCD Exam Study Kit Java Business Component Developer Certification for EJB
确实,你也想通过Su n认证业务组件开发人员(SCBCD)考试,但不仅如此,你还需要真正把EJB用到实处。你要构建应用,要对付最后期限,如果通过考试之后第二天早上就把你学过的EJB知识忘得一干二净,你肯定会受不了。 ...
通过 SUN Java(SCJP、SCWCD、SCBCD)以及 Oracle OCA 等的认证。 > 斗鱼直播 > > B 站录播 沟通交流 Apache Dubbo开源讨论群”群的钉钉群号: 21973601 Spring Cloud Alibaba 开源讨论群”群的钉钉群号: ...
Product Description RFID is a method of remotely storing and receiving data using devices called RFID tags.... SCBCD Exam Study Kit: Java Business Component Developer Certification For EJB.
「小马哥技术周报」 「小马哥技术周报」是小马哥在斗鱼平台的技术分享直播,通常时间安排在每周五晚上八点半,具体通知请关注微信公众号: ...通过SUN Java(SCJP,SCWCD ,SCBCD)以及Oracle OCA等的认证。 着书
Latest EJB3.1 book for JEE6 Oracle Certification