EJB Beginners Questions and Answers

Source: Internet
Author: User
Tags constructor sessions tomcat

1. What are the contents of EJB2.0? The difference between EJB2.0 and EJB1.1?

A: The specification includes the bean provider, the application assembler, the EJB container, the EJB Configuration tool, the EJB service provider, and the system administrator. Within this, the EJB container is the core of the EJB's ability to run. The EJB container manages the important core tasks of creating, undoing, activating, living, and connecting to the database. Jsp,servlet,ejb,jndi,jdbc,jms .....

2. What is the difference between EJB and Java bean?

A: Java beans are reusable components, and there is no strict specification for Java beans, and in theory, any Java class can be a bean. Typically, however, because Java beans are created by containers (such as Tomcat), the Java bean should have a parameterless constructor, and in addition, Java beans typically implement the serializable interface for the persistence of the bean. Java beans actually correspond to local in-process COM components in the Microsoft COM model, which cannot be accessed across processes. Enterprise Java beans are equivalent to DCOM, a distributed component. It is Java based remote method call (RMI) technology, so EJBS can be accessed remotely (across processes, across computers). But EJBs must be in containers such as Webspere, WebLogic, and EJB clients never directly access the real EJB components, but through their containers. The EJB container is the proxy for the EJB component, which is created and managed by the container. The customer accesses the real EJB component through the container.

3, EJB is based on what technology to achieve? And to say the difference between Sessionbean and Entitybean, Statefulbean and Statelessbean differences.

A: EJB includes session beans, Entity beans, message driven beans, based on the techniques of Jndi, RMI, and Jat.

Sessionbean is used in the Java EE application to perform some server-side business operations, such as accessing the database and invoking other EJB components. Entitybean is used to represent the data used in the application system.

For clients, Sessionbean is a Non-persistent object that implements some of the business logic that runs on the server.

For clients, Entitybean is a persistent object that represents an object view of an entity that is stored in persistent storage, or an entity that is implemented by an existing enterprise application.

The session bean can also be subdivided into Stateful session beans and stateless session beans, both of which can put system logic into method execution, unlike Stateful The session Bean can record the state of the caller, so typically, a user has an entity that corresponds to the Stateful sessions bean. The stateless session bean, while also a logical component, is not responsible for recording the user state, meaning that when the user calls the stateless session bean, the EJB Container does not look for a specific stateless Ses Sion the Bean's entity to execute this method. In other words, it is likely that several consumers will execute the Instance of the same bean when executing the methods of a stateless session bean. In terms of memory, the Stateful session bean is compared to the stateless sessions bean, which consumes more memory than the Java Server, but Stateful Sessio The advantage of the N Bean is that he can maintain the user's state.

4. What is the difference between EJB and Java bean?

A: Java beans are reusable components, and there is no strict specification for Java beans, and in theory, any Java class can be a bean. Typically, however, because Java beans are created by containers (such as Tomcat), the Java bean should have a parameterless constructor, and in addition, Java beans typically implement the serializable interface for the persistence of the bean. Java beans actually correspond to local in-process COM components in the Microsoft COM model, which cannot be accessed across processes. Enterprise Java beans are equivalent to DCOM, a distributed component. It is Java based remote method call (RMI) technology, so EJBS can be accessed remotely (across processes, across computers). But EJBs must be in containers such as Webspere, WebLogic, and EJB clients never directly access the real EJB components, but through their containers. The EJB container is the proxy for the EJB component, which is created and managed by the container. The customer accesses the real EJB component through the container.

EJB includes (Sessionbean,entitybean) the life cycle, and how to manage the transaction?

The lifecycle of the sessionbean:stateless session Bean is determined by the container, and when the client issues a request to establish an instance of a bean, the EJB container does not necessarily create a new instance of the bean for the client to invoke. Instead, find an existing instance to provide to the client. When the client invokes a stateful session bean for the first time, the container must immediately create a new Bean instance on the server and associate it with the client, which later calls the stateful session bean method, the container assigns the call to the bean instance that is associated with the client.

Entitybean:entity beans can survive for a relatively long time, and the state is continuous. As long as the data in the database exists, Entity beans is still alive. Rather than according to the application or service process. Even if the EJB container crashes, Entity beans is alive. The Entity beans lifecycle can be managed by the container or beans itself.

EJB uses the following technical management practices: Object Management Organization (OMG) Object Practice Service (OTS), Sun Microsystems Transaction Service (JTS), Java Transaction API (JTA), Development Group (x/ Open) XA interface.

5, EJB roles and three objects

A: A complete EJB based distributed computing structure consists of six roles, which can be provided by different developers, and each role must follow the EJB specification provided by Sun to ensure compatibility with each other. These six roles are EJB component developers (Enterprise Bean Provider), application group (application assembler), Deployer (deployer), EJB server provider (EJB server-based Provider ), EJB container provider (EJB Container Provider), system administrator (sysadmin)

The three objects are the remote (local) interface, the Home (Localhome) interface, and the Bean class

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.