-
statless bean is put in a pool serving many client
-
statful bean serves one client only and destroyed after one session ends
-
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
-
-
Must not define a class
-
Not try to acess security configuration object such as identifier, Signer, provider, security
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 |
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 Object reference
-
Home Object reference
-
EJB context reference
-
JNDI naming context