Technologies and platforms favored by large projects

Source: Internet
Author: User

The frameworks mentioned earlier have one thing in common, that is, they are all open-source and free, and those frameworks do not belong to Java EE specifications. These framework technologies can be used in the face of Small and Medium-sized applications, but they are a little stretched in front of large applications.

1. JSF framework

JSF is short for Java Server faces. Like tapestry, JSF is also a component-based MVC development framework and a technology different from the traditional web development process. JSF was launched by Sun because Sun is famous, so the official Java EE web layer solution is still JSF. In addition, unlike tapestry Based on servlet, JSF is Based on JSP.

In Java ee 5, JSF is just a standard. Every vendor and organization can develop their own implementations according to the standard requirements. Common JSF implementations include sun JSF, MyFaces, facelets JSF, and so on. When developing Web applications using JSF, you will not experience the traditional request-response process. Like tapestry, the main component of JSF is the page. Each page has a page bean in the background, which binds data to the front-end page.

For example, the front-end page contains a user logon component, which must contain two spaces: user name and password, therefore, the response strings in the backend page bean represent the user name and password respectively as the data model of the front-end page.

When you modify the value of the control variable on the foreground page and submit the page, the data model of the bean On the background page changes immediately. On the contrary, changes in the background data are also reflected in the front-end controls, which makes JSF web development more similar to the Development of desktop programs such as swing.

Assume that you want to change the age of your account. According to the JSF request processing process, each step of the request and the event triggered accordingly are as follows:

1) restore the view

Search for or create a component tree for the selected page to restore the component that constitutes the view. The component value may come from the user's request or data stored on the server. Some components generate action time objects in this status. In this example, after the user fills in the age modification information and clicks confirm Niu submits the form, the background needs to reproduce the page component of the user's age modification, so as to proceed to the next step.

2) application request Value

In the restored view, each component finds its own value from the request object submitted by the user, stores the found value, and performs syntax verification on the value of each component. In this example, the username and age equality extracted from the request are re-copied to the recovered component. Syntax verification is different from the subsequent semantic verification. In this example, check whether the input age is an integer.

3) process verification

In the verification phase, check whether the new value in the request meets the requirements. If an exception occurs, an exception message is thrown. In this example, check whether the age value submitted by the user meets the actual conditions, for example, it cannot be a negative number or a large positive integer.

4) update the Model Value

Update the verified group to the attributes of the bound model object, that is, modify the values of the corresponding variables in the bean on the page according to the component values on the page, and correspond to this example, modify the user name and age attributes of the bean On the background page.

5) Call the application

Call the registered listener (such as actionlistener) to process the new value of the model object. In this example, modify the database and replace the user's age with a new value.

6) present a response

For previous requests, a proper view is returned to the client based on the navigation logic. In this example, a page component indicating successful or failed modification is returned to the client browser.

Because JSF components and labels are highly encapsulated, developers do not need to process HTTP details in typical applications. Page operations are automatically mapped to the background JavaBean, and the processing logic Directly Interacts with the background JavaBean. In addition, JSF uses pojo as the controller, so it is flexible and can use any method to process user requests, however, the Controller of struts 2 must be a class that implements the action interface or inherit from the actionsupport class. The code for processing user requests can only be written to the execute method.

2. EJB 3.0 Service Layer Technology

EJB is short for Enterprise Java Bean. Like JSF, EJB is the specification of Java ee. EJB works at the business layer, which is the same as spring, but the advantage of EJB over Spring lies in its distributed capability and remote calls. EJB is a heavyweight solution for massive business volumes, while spring is only a lightweight framework technology. EJB must be deployed in EJB containers such as Weblogic and JBoss. The latest version of EJB is EJB 3.0.

EJB 3.0 is mainly divided into session bean and message-driver bean. The former is mainly responsible for developing synchronous service functions, while the latter focuses on Asynchronous services. Session beans can be divided into stateful Session Bean and stateless Session Bean ).

The foundation of EJB is RMI, that is, remote method invoke, and remote method call. "Pojo + poji" is the focus of EJB 3.0 development. pojo has been introduced earlier, and pojo refers to plain Java interface. "Pojo + poji" means to develop ejbs using common Java objects and interfaces.

3. JPA Persistence Layer Technology

Called Java persistence API, JPA is a complete persistent layer solution in Java ee 5. JPA and Hibernate are at the persistence layer, but JPA is not a substitute for hibernate. Because JPA is a specification that can be implemented by many vendors, and JPA is also implemented in hibernate.

The emergence of JPA summarizes the entity beans with poor performance in EJB 2.x. Now JPA is the best choice for Java EE persistent layer technology. Coupled with JSF and EJB 3.0, the three constitute the official Java ee 5 solution and have also become a complete set of solutions widely used by large projects.

JPA features: JPA absorbs the advantages of many mainstream persistence layer frameworks, such as the hibernate ORM tool. At the same time, JPA is not bound to the Java EE container, so it can be used and tested in the Java SE environment. In addition, JPA defines the service provider interface. developers can use different persistence providers without modifying the entity code, as long as they provide persistent storage solutions.

What is entity?

Entities are different from object beans. They are different objects and entities are not the successor products of object beans. They are a completely new programming concept. In typical multi-tier enterprise applications, there are usually two different objects.

1) business logic components

Such components provide business methods to complete specific business logic, such as calculating user orders based on unit prices and opening bills for customers' credit cards. in EJB 3.0, this type of exclusive access is generally implemented by the Session Bean.

2) persistent data objects

Different persistence mechanisms can be used to store Java objects in persistence sources. Such objects are used to represent data, such as bank account information and human resource data. In JPA, these persistent objects are called objects.

JPA advocates the pojo programming model, so in JPA, all entities are pojo, and developers can persist it to the persistent source (database or legacy system. An object stores data as an attribute and can be associated with the corresponding attribute through a method.

The object class must be declared gradually, which is similar to the database table. At the same time, the entity can not only have access attributes, but also some business methods, such as deducting the account balance and saving funds to the account. Objects in JPA are local objects and cannot be accessed remotely. If remote access is required, Session Bean is generally used to encapsulate the object. The following describes the steps for implementing the entity in the JPA specification.

Load data from the persistent source and provide attribute fields to store the loaded data.

Modify the value of data by modifying the Java object in the memory.

Store the data back to the persistent source to update the persistent data.

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.