EJB Learning History 1 --- Pick

xiaoxiao2021-03-06  56

In order to seek new progress, I think I started learning EJB programming from today.

I hope that all kind-of-minded friends can participate in it.

I am using the reference book is the Wrox EJB Programming Guide. This book has more than 1,000 pages, and strive to complete him all!

Ok, I don't have to say it. Now start to enter the first chapter.

Chapter 1 Enterprise JavaBeans System.

A large stack of nonsense will begin, and the multi-layer architecture is told from the single-layer architecture, and the N-layer architecture is said. This leads out the subject (J2EE). But this sentence is good: Others need special attention () server resources including threads, database connections, security, transactions, and more. Customization of the infrastructure of these resources is quite hard. This work is impossible in the Internet environment. If your development cycle is only three months, is it possible to establish a connection pool, an object buffer or a "wonderful" object layer for database access?

gosh! Said a big pile, finally got a great J2EE. But if you don't know the N-layer structure, you should look!

Container: It is said that the container is the operating environment of the Java program. I don't know if my understanding is correct. Now, you can only understand this.

The book says that the J2EE specification defines four container types:

1. Applets.

2. Application customer container. (I think it is swing)

3. Web container (Servlet and JSP)

4. EJB container.

It seems that 123 have been mastered, and now it is 4, so the EJB container is still learning! ~

The book writes a more in-depth explanation on EJB: EJB is a distributed component model that develops secure, scalable, transactional multi-user components. Simply put, EJB is a reusable software unit that contains business logic. As JSP can separate the application with business logic, EJB can separate application logic and system layer services, enabling developers to consider business issues without having to consider system programming.

J2EE API:

RMI / IIOP: Remote Method Invocation Some things like network connections.

JAVA Naming and Directory Interface.

JDBC: Don't you say this?

JavaMail / Jaf: Java's Mail service, JAF is an accessory for mail.

JMS: Java Message Server. Java message service.

Why use EJB in the design: I said a lot, I am still uncertain. Go again!

However, this time I am more determined, the original EJB container is equivalent to a "function" server, and some business functions can be written. Then use 123 to call! (I don't know if it is a bit funny).

Haha, my understanding is correct, I said the 8th page of the book, the container can be seen as an executive environment!

EJB container service: (The container service here is not encoded, but the container management you are implemented. Good)

Component pool and life cycle management:

Haha, come to the vernacular, this is my personal understanding, the component pool has generated a lot of bean instances when the container starts, if it is 10, this time the customer 1 is coming, he took Bei1 At this time, others can't use bean1, and then come back to the second customer. He can't take Bean1, you can only take bean2. . . . . . . At this time, the customer 11 came, the container found no bean used him, so I found a bean who now used to use it, but I found that all are occupied, there is no way, I have to regenerate it into him. . Haha, it is so simple, but someone will ask, is this not more to build? It doesn't matter, the container finds that the generated bean is not used, it will be automatically deleted, release the space, release the system resources! Customer session management:

Understand the passivation and activation.

Passivation is to save the customer's BEAN state in the pool.

Activation is to give the customer's bean status to the customer.

Database connection pool:

This seems to be not to talk! Data resource sharing! This named COOL B is.

Transaction management:

The transaction is very expensive!

Verification and access control:

This is very simple!

How to provide services in containers: This part is not written first, then write again, because I don't understand. Haha

EJB Type: ***** This is a key place. *****

Divided into three types:

Session bean: (life is as long as the conversation of our customers)

1. No state session bean.

2. Status Session Bean.

These two beans are very important, but they are told in Chapter 3. Haha, take this!

Entity Bean:

I understand that it is a database bean, just read the contents of the database in Bean, and I don't know how it is read. Don't be very wasting system resources! ? ? ?

The entity bean can be divided into:

CMP (persistence of container management): The container is responsible for the BEAN and the foundation database synchronization.

BMP (persistence of bean management): Here you must program a person responsibility and basic database synchronization! The container calls the programmer to write a good SQL statement when appropriate!

I really don't understand why CMP has I have to have a BMP, and the book is explained:

Sometimes adding design flexibility or support persistence in non-relational storage? ? Is this a human language?

There is also a bit: EJB specification V1.1 allows only one-to-one mapping between instance variables and table columns. Thus, when using this version, if you want to indicate a cumulative object in a plurality of tables in the entity bean, CMP cannot be used, and BMP is used. EJB2.0 specification fixes complex query language! Still very well! ~~~~ But it should be useful! ! I will find it in the future! Ha ha! ~~

Message driver bean. Chapter 6: just wait! Brothers ~~~~

Haha! After reading the first chapter. Look at Chapter 2 tomorrow!

Chapter 1 EJB Development

EJB's role: (specified 6 development and deployment roles) L Enterprise Bean Provider's work tasks as follows: 1. Write the main interface of the bean. 2. Write the BEAN's component interface to declare the various business methods required by the application. 3. Write the implementation class that implements various business methods defined in the remote interface. 4. Write a deployment description item. 5. Package. In fact, writing EJB programmers. As for what is the primary interface, what is the component interface, what is the implementation of the class! Let's die first!

l Application Assembler: It is actually a person who is working with a BEAN provider. Nothing is very useful, also known as industry experts! (just kidding)

l Deployer

l System administrator

l EJB service provider, container provider (two in the book, but I think they should be the same, at least temporarily the same thing)

In fact, it is coming back, some people are not very important, people we have to do are enterprise bean providers.

Develop the first EJB

Happy, I finally have a HelloWorld!

Everyone must remember the few elements of the bean provider! It is very important to expand between the few elements.

The topic of HelloWord is: based on annual salary, provident fund and income tax calculation monthly net income. (Stateless session bean).

EJB customer view:

Local Customers: Use local interfaces and local primary interfaces. Press the reference transmission value.

Remote customers: Using remote interfaces and remote primary interfaces. Press the variable transmission value. There will be java.rmi.RemoteException errors.

Standard design mode is that all access to the business logic layer use session beans, which require a remote interface to enable the client layer to access these session beans. The remaining entities and stateless session beans can see "implementation details" and only publish local interfaces.

This is the original words in the book, do you understand? Anyway, I can only understand 80%. Haha ~~~ followed.

Developer interface: fell! I told a lot of main interfaces before, I remembered it now, I don't know how old this book is written. The primary interface is responsible for controlling the life cycle operation of Bean: generated, delete, and looking. The primary interface is the first contact point of the customer in the bean. The customer gets references through JNDI. In fact, determine JNDI when deploying, not anxious. When the client references the primary interface, the bean can be performed by this interface: l Generate a new instance or look for existing Bean instances. (Local or remote) l Access the EJBMetadata interface (remote). l Sequence references (remote) getting a bean instance. l Delete the bean instance. l Execute the primary business method.

In this example, only the primary interface generates a new instance of beans.

The local interface and remote interface are defined in EJB. (Ejbhome and ejblocalhome). The source of these two interfaces is available.

Method in the EJBHOME interface: getJBMetadata (): Returns the reference to the EJBMetAdata interface to obtain Bean information. (Still don't know what EJBMetadata is something. That dictionary is the meant of metadata). GethomeHandle (): Returns the handle of the main object. Remove (): Very simple, deleted. Haha, joke, actually different BEAN results, the session bean is putting the bean back into the pool, and the entity bean is deleted from the database. This time is it! The lower side is the program, I will try the programs to take a moment to talk about it!

转载请注明原文地址:https://www.9cbs.com/read-114586.html

New Post(0)