Question

In: Computer Science

Explain how an EJB container treats an EJB and a POJO differently and why EJB containers...

Explain how an EJB container treats an EJB and a POJO differently and why EJB containers can support one of the Java EE goals: ease of use.

Solutions

Expert Solution

EJB full form is Enterprise Java Beans, EJB container may holds Java programming language server components or business logic and provides local and remote access to enterprise beans. EJBs today are usually "bigger, stronger, faster (or at least more scalable) and simpler" than POJOs. They are most valuable for servicing large numbers of users over the web or corporate network and somewhat less valuable for small apps within a department.EJBs can be packaged in their own jars, deployed, and invoked from lots of places. They are common components. True, POJOs can be (carefully!) designed as libraries and packaged as jars. But EJBs support both local and remote network access - including via local java interface, transparent RMI, JMS async message and SOAP/REST web service, saving from cut-and-paste jar dependencies with multiple deployments.

  An EJB container will provide the runtime environment for EJB applications within the application server.It is responsible for all the operations of the EJB applications.The container acts as an intermediary action between the business logic of the bean and the rest of the world of the enterprise application.The role of EJB container is to perform transactional actions such as - i)Starting a transaction,ii) Rollback a transaction or commit a transaction,iii) Managing various connection pools for the database resources,iv)Bean’s instance variables with corresponding data items which are stored in a database will be synchronized.

In other way POJO(Plain Old Java Object)  It is an ordinary Java object, not bound by any special restriction other than those forced by the Java Language Specification and not requiring any classpath. POJOs have gained the most acceptance because they are easy to write and understand. They were introduced in EJB 3.0 by Sun microsystems.POJO is an object which encapsulates Business Logic. Beans are special type of Pojos ,There are some restrictions on POJO to be a bean container- i) All JavaBeans are POJOs but not all POJOs are JavaBeans. ii)Fields should be private. This is to provide the complete control on fields.iii) Fields should have getters or setters or both.iv) A no-arg constructor should be there in a bean.v)Fields are accessed only by constructor or getter setters.

EJB container treats EJB and POJO differently because they have some difference-

EJB POJO
It is a special POJO which have some restrictions. It doesn’t have special restrictions other than those forced by Java language.
It provides complete control on members. It doesn’t provide much control on members.
Fields are accessed only by getters and setters. Fields can be accessed by their names.
Fields have only private visiblity. Fields can have any visiblity.
It is used when you don’t want to give restriction on your members and give user complete access of your entity It is used when you want to provide user your entity but only some part of your entity.

EJB containers suport java EE goals ,The Java Platform, Enterprise Edition (Java EE) provides a standards-based platform for developing web and enterprise applications. These applications are typically designed as multitier applications, with a frontend tier consisting of web frameworks, a middle tier providing security and transactions, and a backend tier providing connectivity to a database or a legacy system.Java EE platform defines APIs for different components in each tier, and also provides some additional services such as naming, injection, and resource management that span across the platform. Each component is defined in a separate specification that also describes the API, javadocs, and expected behavior.Three Main goals of the platforms are, One of the Goal is

Ease of use -

The Java EE 6 platform takes ease of use to new heights by extensively using convention over configuration and heavy use of annotations on a Plain Old Java Object (POJO). Adding @Stateless  @Stateful, or @Singleton to a POJO makes it an Enterprise JavaBean. Further, this could be easily packaged in a WAR file instead of a special packaging of JAR or EAR. Servlets are POJOs as well, annotated with @Webservlet. Deployment descriptors like Web.XML and Config.XML are optional in most cases; the information typically specified in deployment descriptors is now captured in annotations. There are default rules of navigation from one page of JSF to another. Publishing a POJO as a RESTful web service is equivalent to adding an @Path annotation on a POJO.Making deployment descriptors optional, using convention over configuration, and relying heavily on annotations makes the Java EE 6 platform easy to use and, above all, less verbose.


Related Solutions

Discuss how transfers and distributions are taxed differently. Explain why.
Discuss how transfers and distributions are taxed differently. Explain why.
Consider two containers A and B where A is a rigid container and B is a...
Consider two containers A and B where A is a rigid container and B is a container with a massless, frictionless piston that maintains constant pressure. NH3 (g) is injected into both containers and allowed to come to equilibrium. At equilibrium, 2 atm of Argon gas is injected into each container. Explain any changes (up, down or no change) to the equilibrium concentrations of NH3 , N2 and H2 ? a) do the partial pressures of container A change or...
Explain why capital assets are treated differently in financial management and budgeting. How are these differences...
Explain why capital assets are treated differently in financial management and budgeting. How are these differences accommodated into budgetary and financial management practices?
Two containers of the same volume are evacuated. Container 1 is maintained at a temperature of...
Two containers of the same volume are evacuated. Container 1 is maintained at a temperature of 400 K and filled with oxygen gas to a pressure of 750 mm Hg. Container 2 is maintained at a temperature of 200 K and filled with hydrogen gas to a pressure of 750 mm Hg. Compare the two samples of gas quantitatively with regard to: a. Number of molecules b. Mass c. Average molecular kinetic energy d. Average molecular speed (rms)
Explain why you think that borrowers of money and lenders of money view inflation differently. How...
Explain why you think that borrowers of money and lenders of money view inflation differently. How do borrowers normally react to high inflation rates? How do lenders normally react to high inflation rates? Discuss whether you feel that there are some positive (good) aspects to high inflation. If you don’t feel that there are any, explain why.
In C++ please. 5. Define container adapters that we studied. Explain why container adapters more suitable...
In C++ please. 5. Define container adapters that we studied. Explain why container adapters more suitable for some tasks than regular sequential container. State one container adapter and describe operations that are available for this adapter.
1. You’ve been hired by a company that makes rectangular storage containers. Each container has a...
1. You’ve been hired by a company that makes rectangular storage containers. Each container has a square base and each container must have a volume of 10 m^3. The material for the base and top costs $6/m^2 and the material for the four sides costs $4/m^2. Find the dimensions of the container that minimize the cost of each container. 2. You want to impress your boss by creating a general strategy for finding the dimensions of the cheapest storage container...
1. You’ve been hired by a company that makes rectangular storage containers. Each container has a...
1. You’ve been hired by a company that makes rectangular storage containers. Each container has a square base and each container must have a volume of 10 m^3. The material for the base and top costs $6/m^2 and the material for the four sides costs $4/m^2. Find the dimensions of the container that minimize the cost of each container. 2. You want to impress your boss by creating a general strategy for finding the dimensions of the cheapest storage container...
Explain how the same protein can migrate differently on SDS page
Explain how the same protein can migrate differently on SDS page
Explain why quantum mechanics explain the turn-on voltage of differently colored LEDs. Use words, equations, and...
Explain why quantum mechanics explain the turn-on voltage of differently colored LEDs. Use words, equations, and diagrams
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT