Session bean
1.1 for at least one rule must have a 1.2 session bean business interface type must be concrete, not abstract or final is the 1.3 must have a constructor without parameters in the bean type 1.4 or type in the definition of his father and the life cycle of business 1.4.1 Session bean callback methods to support the annotation of the succession at 1.5 has a number of restrictions on type of session bean can be another session bean, or any other sub-categories pojo business methods should not be 1.6 to 1.6.1 at the beginning of ejb may interfere with the basic ejb 1.6.2 Business structure Ways must be public and static can not be final and 1.6.3 of the remote interface if the method of exposure, we must ensure that the parameters and return type of interface implementation java.io.serializable
Conversation conversational state status 2
2.1 stateful bean
2.1.1 Modeling many steps to deal with 2.2 stateliss bean
2.2.1 Modeling of the general usefulness of the 3 lifecycle callback Services
3.1 annotation
3.1.1 postConstruct
3.1.1.1 stateful, stateliss, MDB
3.1.1.1.1 bean is created and dependency injection, the initialization of resources 3.1.2 preDestory
3.1.2.1 stateful, stateliss, mdb
3.1.2.1.1 Prior to the destruction of bean called to clean up resources 3.1.3 postActivate
3.1.3.1 stateful
3.1.3.1.1 activated, the reply of resources 3.1.4 prePassivate
3.1.4.1 stateful
3.1.4.1.1 before passivation to remove the resources marked 3.2 Note the method used, it can be private, protected, public, package-protected the
4 stateless session bean
4.1 @ stateless
4.1.1 name: bean name 4.1.2 mappedName: proprietary vendor name, number of containers to use this name jndi name of the overall assignment 4.1.3 description: description of 4.2 business interfaces
4.2.1 @ Local
4.2.2 @ Remote
4.2.2.1 interface method parameters and return values must be serialize the 4.2.3 @ WebService
4.2.4 can not visit more than one type of marking an interface 4.2.5 to expand a business interface to another interface in the bean category 4.2.6 can be used in Notes, but does not achieve the operational interface 4.2.6.1 @ Remote (BidManager. class)
4.3 lifecycle callback
4.3.1 or interceptors of a given bean can have more than one callback postConstruct and preDestory
5 stateful session bean
5.1.1 Additional Rules 5.1 session state storage of the field must be the original type or Object Serializable Notes 5.1.2 @ Remove client-side delete the bean instance to use 5.1.3 prePassivate postActivate
5.2 passivate the nature of passivation passivation 5.2.1: bean serialization will be saved to disk 5.2.2 @ prePassivate
5.2.2.1 serial will be of value to a copy of the variables serial 5.2.2.2 release of heavy resources to remove unnecessary data 5.2.2.3
6 compare between stateless and stateful bean
Conversation 6.1 no 6.1.1 status: no
6.1.2 there is: yes
6.2 and 6.2.1 No pool: yes
6.2.2 there is: no
6.3 Performance 6.3.1 no problem: there is not likely to 6.3.2: 6.4 possible without life-cycle 6.4.1 Case: postConstruct, preDestory
6.4.2 there is: postConstruct, preDestory, postActivate, prePassivate
6.5 Timer 6.5.1 free: yse
6.5.2 there is: no
6.6 for services sessionSynchronization
6.6.1 no: no
6.6.2 there is: yes
6.7.1 Services 6.7 web-free; yes
6.7.2 there is: no
6.8 Extended persistenceContext
6.8.1 no: no
6.8.2 there is: yes
7 session bean clients
7.1 was 7.1.1 ejb invoke ejb search 7.1.2 jndi context 7.1.3 search 7.1.3.1 @ EJB dependency injection
7.1.3.1.1 name: in the environment naming context used to inject the jndi name of ejb
7.1.3.1.2 beanInterface
7.1.3.1.2.1 Service Interface 7.1.3.1.3 beanName
7.1.3.1.3.1 distinction bean, if the number of components ejb achieve an operational interface with 7.1.3.2 only managed environment 7.1.3.2.1 other ejb
7.1.3.2.2 Medium Acc code running on the use of web containers 7.1.3.2.3 Component 7.1.3.3 register has status should not be injected into the bean in the bean-free status
8 stateful bean properties 8.1 Notes session data 8.1.1 Choose the appropriate storage to avoid large objects and delete bean passivation 8.2
8.3 lasting alternative to 8.3.1 and 8.3.2 deal with non-state structure on the client to maintain the status 8.3.2.1 a mechanism difficult to ensure high-availability, loss of containers to provide the advantages of web layer in the 8.3.3 client, in web container session to preserve the use of session state 8.3.3.1 session over the same servlet container may result in performance degradation
9 Best Practices 9.1 carefully select the type of bean status 9.1.1 there is the cost of the session bean will be 9.1.2 if the client can be considered in the web layer httpServlet
9.2 careful analysis of the type of session bean interface 9.2.1 If the client and the bean in the same jvm run, is to use local interface 9.3 If you use dependency injection, not to put into the stateful bean in the stateless bean cross section of 9.4 to separate matters 9.4.1 9.5 interceptors careful analysis at the session bean type of data stored in 9.5.1 as far as possible the use of stateful bean in the original type of variable, rather than in line with the targets of large-scale nested 9.6 stateful bean must not forget that in the @ Remove method of the definition of passive and adjust 9.7 activated configuration, the application to find the best value