Lesson 13
Transactions/remote objects for Entity Beans Conclusion
In this module we explored how EJBs interact within the context of a distributed transaction.
JTS and JTA
The two packages were introduced.
- Java Transaction Services (JTS) and
- Java Transaction API (JTA).
JTS is the underlying architecture that supports distributed transactions and JTA is the programmers API used to access the services.
You were introduced to a
transaction being an
atomic unit of work that is executed by a
single thread of control .
Transactions involving multiple
recoverable resources require two-phase commits. The transaction manager synchronizes the activities between the recoverable and transactional resources.
Managed transactions
You were introduced to the three different ways a transaction can be managed:
- client-managed where the client begins and commits the transaction;
- bean-managed transactions that are started and controlled by the bean; and
- container-managed transactions where the EJB knows nothing about the transaction that the container is managing for it.
For bean-managed transactions, you were introduced to the transaction controls that are set in the deployment descriptor. The specification that controls the transaction attributes for a method is known as a
transaction control .
Session synchronization and EJBContext
You were introduced to the idea that session beans can be involved in transactions. If they are container managed, the session bean still may need to know or affect the outcome of a transaction.
The SessionSynchronization object allows that session bean to synchronize itself with the transaction. The EJBContext allows the session bean to affect or test the outcome of a transaction.
Exceptions
Finally, you were introduced to the exceptions that may be thrown and caught from the transaction service.
Bean Managed Transaction Exercise
Click the Exercise link to test your understanding of transactions by completing the course project exercise that applies transactions to the BankAccount bean.
Bean Managed Transaction Exercise
Developers today increasingly recognize the need for distributed, transactional, and portable applications that leverage the speed, security, and reliability of server-side
technology. Enterprise applications provide the business logic for an enterprise. They are centrally managed and often interact with other enterprise software. In the world of information technology, enterprise applications must be designed, built, and
produced for less money, with greater speed, and with fewer resources.
With the Java Platform, Enterprise Edition (Java EE), development of Java enterprise applications has never been easier or faster. The aim of the Java EE platform is to provide developers with a powerful set of APIs while shortening development time,
reducing application complexity, and improving application performance.
The Java EE platform is developed through the Java Community Process (JCP), which is responsible for all Java technologies. Expert groups composed of interested parties
have created Java Specification Requests (JSRs) to define the various Java EE technologies. The work of the Java Community under the JCP program helps to ensure Java technology's standards of stability and cross-platform compatibility.
The Java EE platform uses a simplified programming model. XML deployment descriptors are optional. Instead, a developer can simply enter the information as an annotation directly into a Java source file, and
the Java EE server will configure the component at deployment and runtime. These annotations are generally used to embed in a program data that would otherwise be furnished in a deployment descriptor.
With annotations, you put the specification information in your code next to the program element affected.
In the Java EE platform, dependency injection can be applied to all resources a component needs, effectively hiding the creation and lookup of resources from application code.
Dependency injection can be used in Enterprise JavaBeans (EJB) containers, web containers, and application clients. Dependency injection allows the Java EE container to automatically insert references to other required components or resources,
using annotations.
In the next module you will be introduced to the architecture and design of entity beans.