Technologies and platforms favored by large projects

Source: Internet
Author: User
Tags sessions java se

All of the previous frameworks have one thing in common: all open source is free, and those frameworks don't belong to Java EE specifications. These framework technologies are more comfortable in the face of small and medium-sized applications, but are stretched in front of large applications.

1. JSF Framework

JSF is the abbreviation for Java Server faces, and like tapestry, JSF is also a framework for MVC development based on component technology, a technology that distinguishes itself from traditional web development processes. JSF was launched by Sun, because Sun is so famous that the official Java EE Web Layer solution is JSF. And unlike Tapestry, which is based on a servlet, JSF is based on JSP.

In Java EE 5, JSF is just a standard, and vendors and organizations can develop their own implementations based on standard requirements, and common JSF implementations include Sun JSF, Myfaces, Facelets JSF, and so on. When you use JSF to develop a Web application, you will not appreciate the traditional process of request-response. As with tapestry, the main component of JSF is the page, and each page has a page bean in the background, and the page bean is bound to the front page itself.

For example, the front page contains a user login component, this login component must contain the username and password two space, so the background of the page bean in response to two of the user name and password on behalf of the string as the front page data model.

When the user modifies the value of the control variable on the foreground page and submits the page, the background page bean's data model changes immediately. Conversely, changes in the background data will also be reflected in the foreground controls, which makes the JSF web development more akin to the development of desktop applications such as swing.

Assuming that the user wants to change the age in his or her account, each step of the request and the corresponding triggering event are as follows, depending on the JSF request processing process:

1) Restore View

To find or create a component tree for the selected page, restore the components that make up the view, and the component values may come from a request from the user or data stored on the server side. One of the things is that some components will be in this state of the time object. For this example, when the user fills out the modified age information and clicks OK The chick submits the form, the background needs to reproduce the Modified Age page component that the user fills in for the next step.

2 Apply Request Value

In a restored view, each component finds its own value in the request object submitted by the user and stores the values found, along with a syntax validation of the values for each component. For this example, the user name and age equivalent extracted from the request are copied back to the restored component. Syntax validation differs from subsequent semantic validation, as in this example checking whether the age of the input is an integer.

3) Processing Verification

Processing the validation phase checks whether the new value in the request satisfies the requirement, and if an exception is thrown, an exception message is raised, which, in this case, checks whether the user submits an age value that is realistic, such as a positive integer that cannot be negative or too large.

4) Update model values

The validated group is simply updated to the bound Model object property, which modifies the value of the corresponding variable in its page bean based on the page component value, which, in this case, modifies the user name and age attribute of the background page bean.

5) Invoke the application

Call a registered listener (such as ActionListener) to handle the new value of the model object, and in this case, modify the database to replace the user's age with the new number.

6) Rendering response

For the previous request, return a suitable view to the client according to the navigation logic, and in this case, return the prompt to modify the page component of success or failure to the client browser.

Because JSF components and tags are highly encapsulated, there is no need for developers to deal with HTTP details in a typical application. The page actions are automatically mapped to the JavaBean in the background, and the processing logic interacts directly with the JavaBean in the background. In addition, JSF uses Pojo as the controller, so it is more flexible and can use any method to handle the user's request, but Struts 2 's controller must be a class that implements the action interface or inherits from the Actionsupport class, The code that handles user requests can only be written to the Execute method.

2, EJB 3.0 Business layer Technology

EJB is the abbreviation of Enterprise Java Bean, like JSF, EJB is the specification of Java EE. EJB works at the business level, which is the same as spring, but the advantage of EJB over spring is that it has distributed capabilities that can be invoked remotely. EJB is a heavyweight solution for a huge business volume, and spring is just a lightweight framework technology. EJB must be deployed in the EJB container such as WebLogic, JBoss, and so on, the current EJB version is EJB 3.0.

EJB 3.0 is primarily divided into session (sessions) beans and message-driven (message-driver) beans. The former is mainly responsible for the functional development of the synchronous business, while the latter focuses on the asynchronous business. Session beans can also be divided into stateful session beans (Stateful session beans) and stateless conversation beans (stateless sessions beans).

The base of the EJB is RMI, remote method Invoke, which is called remotely. The development of EJB 3.0 is about "Pojo+poji", as POJO described earlier, POJO refers to plain Java Interface. The meaning of "Pojo+poji" is to develop EJBS with ordinary Java objects and interfaces.

3. JPA Persistence Layer Technology

JPA is all called the Java Persistence API and is a complete persistence layer solution in Java EE 5. JPA is in a persistent layer with hibernate, but JPA is not a substitute for hibernate. Because JPA is a specification that can be implemented by a number of vendors, Hibernate now has the implementation of JPA.

The presence of JPA summarizes the poorly performing entity beans in EJB 2.x, and now JPA is the choice of Java EE Persistence layer technology. Together with JSF, EJB 3.0, the three are the official solution of Java EE 5, as well as a complete set of solutions commonly used by large projects.

JPA Features: JPA absorbs many of the benefits of the mainstream persistence layer framework, such as Hibernate ORM tools. While JPA does not have a container bound to Java EE, it can be used and tested in the Java SE environment. In addition, JPA defines the service provider interface (Provider Interface), where developers can use different persistence providers without modifying the entity code as long as they can provide a durable storage solution.

What is an entity.

Entities are different from entity beans, they are different objects, and entities are not the successor of entity beans, a new programming concept. In a typical multi-tier enterprise application, there are usually two different objects.

1) Business logic Components

This type of component provides a business method that can accomplish specific business logic, such as calculating user orders based on unit price, billing a customer's credit card, and so on, in EJB 3.0, which is typically implemented by the session bean.

2 Persistence of Data Objects

Different persistence mechanisms enable Java objects to be stored in a persistent source, which is used to represent data such as bank account information, human resources data, and so on. In JPA, these persisted objects are called entities.

JPA advocates the Pojo programming model, so in JPA, entities are pojo, and developers can persist them to persistent sources (databases or legacy systems). Entities to store data as attributes, you can associate them with the corresponding property by means of a method.

Entity classes must be declared gradually, which is similar to a database table. At the same time, the entity can not only have access to the property of the method, but also by a certain business methods, such as deducting the balance of accounts, to the account deposit funds. Entities in JPA are local objects and cannot be directly accessed remotely. If remote access is required, it is generally packaged with a session bean, and the work steps of the entity in the JPA specification are listed below.

Loads data from a persistent source and provides property fields to store the loaded data.

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

The data is saved back to the persistent source to achieve the purpose of updating the persisted 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.