4.7 Container-Provided Benefits

The previous sections described the tasks required of the session bean developers when developing the Enrollment and Payroll session beans. It is equally interesting to examine the tasks that the bean developers do not have to do because of the services provided by the EJB container. These services are distributed programming, concurrency and multithreading, transaction management, security management, resource pooling and other scalability issues, system administration, and high availability.

  • Distributed programming Because the EJB container handles distributed programming, the session bean developer doesn't have to deal with the complexity of writing a distributed application. To the developer, the session bean classes are Java classes that require no distributed programming knowledge. The EJB container provides the implementation of the session beans' home and remote interfaces by creating distributed RMI-IIOP objects. This allows the Payroll application to be written in the same way, regardless of whether its client (EnrollmentEJB) is deployed on the same machine or on a different machine.

  • Concurrency and multithreading The developer can write the session bean classes as if they were used by one user. The EJB container makes it possible for multiple users to execute the benefits application concurrently. How does the container accomplish this? For the EnrollmentEJB stateful session bean, the container creates a private instance of the EnrollmentBean class for each connected user. In the case of the PayrollEJB stateless session bean, the container multiplexes the requests from multiple users across one or more instances of the PayrollBean class. The bean developer does not have to write any thread synchronization code into the application, because the EJB container does not allow conflicts resulting from multithreading to arise in the enterprise bean code.

  • Transaction management The bean developer does not have to write transaction management code. Note that the EnrollmentBean and PayrollBean classes contain no transaction management related code. The EJB container automatically wraps the business methods into transactions, based on the deployment descriptor information for the bean. For example, the container does the following:

    • Starts a transaction before the execution of the EnrollmentBean.commitSelections method

    • Propagates the transaction to BenefitsDatabase, the PayrollBean.setBenefitsDeduction method, and PayrollDatabase

    • Performs a two-phase commit protocol across the two databases when the EnrollmentBean.commitSelections method has completed

  • Security management The session bean developer does not have to include security-related code in the respective bean implementations. The EnrollmentBean and PayrollBean classes contain no security-related code. The deployer and the system administrator set the security management policies by using facilities provided by the container, which enforces these security policies.

  • Resource pooling and other scalability issues The session bean developer does not have to deal with scalability issues in the bean's code. In our benefits example, the programmer did not have to deal directly with the issue of simultaneous access by a great number of users. That is, What happens if 10,000 employees all logged in to the benefits application and tried to use it at the same time? If such an event did occur, the EJB container would pool expensive server resources, such as JDBC connections, and this pooling would be transparent to the session bean code. Similarly, if the system happened to be low on memory, the EJB container would passivate some session objects and move them temporarily to secondary storage. In addition to being transparent to the bean, this avoids thrashing and achieves optimal throughput and response time.

  • System administration The EJB container provides tools for system administration so that the bean developer does not have to include such code in the application. In the benefits example, the session bean developer didn't have to write code to make the application capable of system administration. The EJB container provides application administration tools that are used by the Star Enterprise IT staff to manage the application at runtime.

  • High availability If it is concerned about the availability aspects of the application, Star Enterprise should deploy the application in an EJB container that provides high availability. The session bean developer does not have to do anything different in the bean's code to make the application highly available.



Applying Enterprise Javabeans
Applying Enterprise JavaBeans(TM): Component-Based Development for the J2EE(TM) Platform
ISBN: 0201702673
EAN: 2147483647
Year: 2003
Pages: 110

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net