Java heavyweight and lightweight concepts

Source: Internet
Author: User

First, lightweight and heavyweight are relative concepts, mainly for the ease of use of the application framework and the service features provided.
For example, EJB is a heavyweight framework, because itCodeIt also provides distributed and other complex functions.
In contrast, spring is a lightweight framework, because it only requires common Java objects, and it provides only enough functions for Small and Medium-sized applications.
However, with the development of spring, it also has more and more powerful functions, and the use of EJB is also becoming simple, so with the development of technology, this probability also needs to be updated. After all, it is used to make a difference with the use of complex frameworks, so this line is not so obvious when each family is constantly absorbing the strengths of each other.

 

Actually: Is it lightweight or heavyweight to divide an application?,It mainly depends on how many services it uses.The more services you use,

The container must be normalJavaObjects do more work.,It will inevitably affect the release time or running performance of the application..

for spring container , it provides very multi-service , however, these services are not enabled by default for applications. , services required by an application , specify the Service to use , If

few services are used by applications , for example, : only spring core services , in this case, we can consider the application to be lightweight. , If the application uses spring provided

Most services,In this case, the application is heavy.QuantityLevel.CurrentlyEJBContainerBecause itBy defaultEJBStandardizingAll contributionsYes,So it belongs to the Heavyweight.

 

In addition, lightweight components are drawn using Java code, which is platform portability.
Heavyweight components are components drawn by calling the functions of the operating system, such as the main form.
Generally, use lightweight components as much as possible.ProgramGood portability
Most of the components in the javax. Swing package are lightweight.
Java. AWT contains Heavyweight

Swing is implemented by 100% pure Java, and the swing component is a lightweight (light-weight) component implemented by Java. It does not have local code and does not rely on the support of the operating system, this is the biggest difference between it and the AWT component. Since the AWT component is implemented through peer implementation related to a specific platform, swing is more practical than the AWT component. Swing performs the same on different platforms and has the ability to provide other features not supported by the local window system.

 

In general:

Heavyweight component: the running platform must have a corresponding component.
Lightweight components: Components drawn on a virtual canvas (So swing is slow). All lightweight components "end up" need to be placed in the heavyweight components (jframe, jdialog. because it is drawn out, it can achieve consistent performance on various platforms. similarly, hybrid heavyweight components and lightweight components may cause overlapping conflicts.

After JDK 1.2, Java has another set of GUI APIs called swing. Swing is a lightweight API, so it is omnipotent. It not only has a variety of advanced components, but also supports component styles. After swing appeared, AWT was not used very quickly.
Do not think that swing is used to replace AWT. In fact, swing is built on AWT (swing has four heavyweight components). Without AWT, there will be no swing. The emergence of swing only reduces the chance for programmers to directly use AWT, rather than making AWT disappear.

 

 

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.