EJB knowledge Q &

Source: Internet
Author: User

1:EJB:

A: Enterprise Java Bean is equivalent to DCOM, which is a distributed component. It is based on Java remote method call (RMI) technology, so EJB can be remotely accessed (cross-process, cross-computer ). However, EJB must be deployed in containers such as webspere and weblogic. The EJB client never directly accesses the real EJB component but accesses it through its container. The EJB container is the proxy of the EJB component. The EJB component is created and managed by the container. The customer accesses the real EJB component through the container.

A: Enterprise Java Bean container. More industry-specific characteristics. It provides various management functions for the component EJB running in it. As long as the EJB meeting the J2EE specification is put into the container, it will be managed efficiently by the container immediately. In addition, system-level services can be obtained through ready-made interfaces. For example, mail service and transaction management.

 

RMI :( Remote Method Invocation) remote method call

A: RMI (Remote Method Invocation) is implemented in Java in jdk1.1 and greatly enhances Java's ability to develop distributed applications. Java, as a popular network development language, has great power in its powerful ability to develop distributed network applications, RMI is one of the core solutions for developing a network distributed application system with hundreds of thousands of pure Java. In fact, it can be regarded as the Java version of RPC. However, traditional RPC cannot be well applied to distributed object systems. Java RMI supportsProgramLevel objects communicate with each other to realize seamless remote calls between remote objects.

2:EJBTypes and Functions

A: Entity Bean -- used to describe a permanent object.

Session Bean: describes the model of a task or workflow and coordinates the interaction between beans.

Message-driver bean-used to process asynchronous JMS messages in J2EE-based applications.

3:EntityBean,CMP, BMPDifferences in writing?

A: The CMP Entity Bean does not need to write database operations in the bean.Code; Can let the container do this.

BMP entity bean directly writes database calls in bean classes and accesses of any type of fixed storage to manage bean persistence.

4:FindAndSelectWhat are the differences between methods?

A:

 

Finder

Select

Return Value

Single object or set, which is ejbobject (s) and ejblocalobject (s) of the bean type ).

One or more (set or set) objects. is the bean type or CMR-related type ejbobject (s) or ejblocalobject (s) may also be a CMP (domain), CMP set or a CMR domain.

Declaration location

In the remote and/or local home Interfaces

Abstract METHODS In bean classes

Method Name

Findxxx ()

Ejbselectxxx-Bean class

Visibility

Publish to client

Internal Entity Bean class for other bean Methods

Instance

Any random bean instance in the bean pool

The current instance. If the home method is called, The instance is random.

 

5:Main Interface Method definition and writing?

A: method for creating a life cycle method-the return value of this method is the bean Component Interface written as creatxxx.

Stateless session beans must be created with only one parameter.

The stateful Session Bean must contain at least one creation method. The entity bean can have at most 0 creation methods.

Finder method-the finder method is effective for Entity Bean. It can be used to find the persistent data corresponding to entity bean in the database. the home interface of each entity bean must have a findbyprimarykey method and take the primary key of the object as the parameter. you can customize the finder method. the Home method-home method is only valid for Entity Bean. the Home method can return any type of serialized objects, but does not actually generate bean instances.

6:Main Interface and Component Interface?

A: the main interface provides access to bean from the EJB client. defines the bean lifecycle method and provides the basic lifecycle management functions of bean, such as creating, deleting, and searching. message Drivern bean does not contain the home interface. the component interface is used by the enterprise Bean client to obtain bean access capabilities. it defines the Business Methods visible to the client. the business methods in the component interface must comply with the implementation in the bean class.

7,JMSMessage transmission method?

A: a point-to-point message is sent through a queue. The publish-and-subscribe, pub/sub messages are delivered by the title.

8,EJBClient Access backendEJBCode?

Answer: p192, p193

9, StatefulSession BeanAnd statelessSession BeanDifference?

A: stateful Session Bean maintains the client session status. they must belong to one and only one client. activation/passivation, high overhead. stateless sessions do not maintain the session Status of a client. They are put into the instance pool, so they can be shared by multiple users, with low overhead and high efficiency.

10Local view and remote view?

A: Remote view-the idea is that remote calls will be executed between two different JVMs. by remotely calling these operations, the related network overhead is higher than that of the object. it does not care whether it is in a JVM.

Local view-the idea is that local calls will be executed in the same JVM. no network overhead. the operation efficiency is higher because the client uses a local object to call the services on the bean, which is restricted to local implementation and does not need to be location-independent.

11:CMTTransaction attributes

 

Mandatory-when this value is used, a transaction must be running when the bean method is called.

Never-if this bean is called in an existing transaction, the container will throw java. RMI. remotexception.

The required-bean method must always be executed in the transaction context.

Requiresnew-when a method is called, the bean always needs to start a new transaction.

Supports can participate in a running transaction, but this transaction is not required.

Not Supported-this value means that the bean or method cannot be called at all in the transaction.

12: Transaction attributesAcid

A: atomicity-a transaction is either completely executed or not executed at all.

Consistency-after a transaction is completed, the system inconsistency cannot be left.

Isolation-all transactions are not allowed to be executed without interference from other processes or transactions.

Durability-during a transaction, all committed change data must be written into the persistent data storage and should be saved in hardware and software failures.

13:EntityBeanThree statuses:

A: No-state -- bean instance has not been created yet.

Pooled-the bean instance has been created but has not been associated with an EJB object.

Ready -- associate with EJB object. If the association is disconnected, the system returns to pooled.

14:JMS,JMSMessage Model

A: Java Message Service (JMS) is a Java API used to access message-oriented middleware (MOM) services. JMS provides a common method for Java programs to generate, send, receive, and read asynchronous messages.

JMS model: point-to-point and release and subscription

Point-to-point-the message is sent through the queue. Messages are put into the queue by the message producer (client. The message consumer is responsible for extracting messages from the queue. P2P is used when a given message can only be received by a given consumer. In this case, the given information has only one consumer.

Publish-and-subscribe (pub/sub for short)-messages are transmitted by titles. The producer publishes the message as the title. A message can be received by any consumer subscribing to this title. In this way, a message can be received or processed by multiple consumers.

15:EJBClient type

Answer: ① Session Bean ② servlet ③ Java application ④ Java Applet ⑤ non-Java client

16:ORM

A: The object-Relation Mapping mode in Orm refers to the persistence of all object domain objects in a single component and encapsulation of data access details.

17:EJBWhat technologies are implemented based on?
EJB includes Session Bean, Entity Bean, and message driven bean, which are implemented based on technologies such as JNDI, RMI, and JAT.

18:NameSessionbeanAndEntitybeanDifference

Sessionbean is used in J2EE applications to perform some server-side business operations, such as accessing the database and calling 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 business logic running on the server.
For clients, entitybean is a persistent object that represents an object view of an object stored in persistent storage or an entity implemented by an existing enterprise application.

19:StatefulbeanAndStatelessbean.

Session Bean can be further subdivided into stateful Session Bean and stateless Session Bean. Both session beans can execute the system logic in method, the difference is that the stateful session bean can record the caller's status. Therefore, a user usually has a corresponding stateful Session Bean entity. Although stateless Session Bean is also a logical component, it is not responsible for recording the user status, that is, when the user calls stateless Session Bean, the EJB container does not find the entity of the specific stateless Session Bean to execute this method. In other words, when several users execute a stateless Session Bean's methods, they will execute the same bean instance. In terms of memory, compared with stateful Session Bean and stateless Session Bean, stateful Session Bean consumes a large amount of memory on the J2EE server, however, the advantage of stateful Session Bean is that it can maintain the user's status.

20 : what is the difference between EJB and Java Bean ?
Java Bean is a reusable component and there is no strict specification for Java Bean. Theoretically, any Java class can be a bean. However, since Java Beans are created by containers (such as Tomcat), Java Beans should have a constructor without parameters. In addition, generally, Java Bean must implement the serializable interface to realize bean persistence. Java Bean is actually equivalent to the COM component in the local process in the Microsoft COM model. It cannot be accessed across processes. Enterprise Java Bean is equivalent to DCOM, which is a distributed component. It is based on Java remote method call (RMI) technology, so EJB can be remotely accessed (cross-process, cross-computer ). However, EJB must be deployed in containers such as webspere and weblogic. The EJB client never directly accesses the real EJB component but accesses it through its container. The EJB container is the proxy of the EJB component. The EJB component is created and managed by the container. The customer accesses the real EJB component through the container.

21:EJBIncluding (Sessionbean, entitybean) Tell them their lifecycles and how to manage transactions?
Sessionbean: the lifecycle of stateless Session Bean is determined by the container. When the client sends a request to create a bean instance, the EJB container does not have to create a new bean instance for the client to call. Instead, it finds an existing instance and provides it to the client. When the client calls 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, when this client calls the stateful Session Bean method later, the container will dispatch the call to the bean instance associated with this client.
Entitybean: entity beans can survive for a relatively long time, And the status is continuous. As long as the data in the database exists, entity beans will survive. It is not based on the application or service process. Even if the EJB container crashes, entity beans survive. Entity beans can be managed by containers or beans themselves.
EJB uses the following technical management practices: ots of Object Management Organization (OMG), Transaction Service (JTs) of Sun Microsystems, and Java transaction API (JTA ), the Xa interface of the Development Group (x/open.

22.EJBRoles and objects

A complete EJB-based Distributed Computing structure consists of six roles, which can be provided by different developers. Each role must follow the EJB specifications provided by Sun, to ensure compatibility between them. These six roles are EJB component developer (enterprise Bean provider), application aggreger (Application aggreger), deployer (deployer), and EJB Server Provider (EJB Server Provider), EJB container provider, System Administrator)
The three objects are remote (local) interface, Home (localhome) interface, and Bean class.

23.EJBWhat services are provided by containers?

It mainly provides declarative cycle management, code generation, continuity management, security, transaction management, lock and release management services.

24.EJBOf

Session Bean, Entity Bean message-driven Bean
Session beans can be divided into stateful and stateless.

Entity beans can be divided into two types: bean management continuity (BMP) and container management continuity (CMP ).

25.EJBThe business interface orHomeInterface? Give a brief description of the reason.

The remote interface and home interface do not need to be implemented directly. Their implementation code is generated by the server. The corresponding implementation class in the program running will be used as an instance of the corresponding interface type.

26InJ2EEInner,WarAndEarWhat files represent.

War: Web Archive. It contains compressed files of all components of a web project.

Ear: An enterprise archive. It contains a compressed file of all components of an enterprise application.

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.