J2EE framework structure and core technology Basics

Source: Internet
Author: User
Tags perl script
  I. J2EE Concept

Currently, the Java 2 platform has three versions. These are the micro version of Java 2 platform (Java 2 platform Micro Edition, j2_based) applicable to small devices and smart cards) java 2 platform Standard Edition (Java 2 platform Standard Edition, j2se) for desktop systems and Java 2 Platform Enterprise Edition (J2EE) for creating server applications and services ). J2EE is an architecture that uses the Java 2 platform to simplify the development, deployment, and management of enterprise solutions. The foundation of J2EE technology is the Standard Edition of the core Java platform or Java 2 platform. J2EE not only consolidates many advantages of the Standard Edition, for example, the features of "writing once and running anywhere", jdbc api for convenient database access, and the technology of CORBA, as well as the security mode that can protect data in Internet applications, etc, it also provides comprehensive support for EJB (Enterprise JavaBeans), Java Servlets APIs, JSP (Java Server Pages), and XML technologies. The ultimate goal is to become an architecture that can greatly shorten the time to market for enterprise developers.

The J2EE architecture provides an intermediate layer integration framework to meet the needs of applications that require high availability, high reliability, and scalability without too much cost. By providing a unified development platform, J2EE reduces the cost and complexity of developing multi-tier applications. It also provides strong support for existing application integration and fully supports Enterprise JavaBeans, A good wizard supports packaging and deploying applications, adding directory support, enhancing the security mechanism and improving performance.

Ii. Advantages of J2EE

1. J2EE provides a good mechanism for building a scalable, flexible, and easy-to-maintain business system and retains existing IT assets:

As enterprises must adapt to new business needs, it is important to use existing investment in enterprise information systems, rather than re-developing a full solution. In this way, a server-side platform mechanism built on an existing system is required by the company in a gradual (instead of radical, totally no) manner. The J2EE architecture can take full advantage of users' original investments, such as BEA Tuxedo, IBM CICs, IBM encina, Inprise VisiBroker, and Netscape application server used by some companies. This may be because J2EE has extensive industry support and the participation of some important vendors in the 'Enterprise compute' field. Every supplier provides existing customers with a way to upgrade to the portable J2EE field without having to discard existing investments. Because J2EE platform-based products can run on almost any operating system or hardware configuration, existing operating systems and hardware can also be retained for use.

2. Efficient development:

J2EE allows companies to deliver some common and cumbersome server tasks to middleware vendors. In this way, developers can focus on how to create business logic and shorten the development time accordingly. Advanced middleware vendors provide the following complex middleware services:

The status management service allows developers to write less code without having to worry about how to manage the status so that they can complete program development faster.
The persistent service allows developers to write applications without coding the data access logic and generate lightweight and database-independent applications, which are easier to develop and maintain.
The Distributed Shared data object cache service allows developers to compile high-performance systems, greatly improving the overall deployment scalability.
3. Supports heterogeneous environments:

J2EE can develop portable programs deployed in heterogeneous environments. J2EE-based applications do not rely on any specific operating system, middleware, or hardware. Therefore, a reasonably designed J2EE-based program can be deployed on various platforms only once for development. This is critical in a typical heterogeneous enterprise computing environment. The J2EE standard also allows customers to order third-party ready-made components compatible with J2EE and deploy them in heterogeneous environments, saving the cost required to develop the entire solution by themselves.

4. Scalability:

Enterprises must select a server-side platform that provides excellent scalability to meet a large number of new customers who operate their systems commercially. Applications based on the J2EE platform can be deployed on various operating systems. For example, it can be deployed to high-end Unix and mainframe systems, which can support 64-256 processors on a single machine. (This is beyond the reach of NT servers) suppliers in the J2EE field provide more extensive Load Balancing policies. Eliminate system bottlenecks and allow integrated deployment of multiple servers. This deployment can reach thousands of processors, achieving highly scalable systems to meet the needs of future commercial applications.

5. Stable availability:

A server platform must be able to run around the clock to meet the needs of customers and partners. Because the Internet is global and ubiquitous, even if it is stopped at night, it may cause serious losses. If an unexpected shutdown occurs, there will be disastrous consequences. J2EE is deployed in a reliable operating environment. They support long-term availability. Some J2EE instances are deployed in windows, and customers can choose Operating Systems with better performance, such as Sun Solaris and ibm OS/390. The most robust operating system can reach 99. 999% availability or 5 minutes of downtime per year. This is an ideal choice for real-time commercial systems.

Iii. J2EE layer-4 Model

J2EE uses a multi-layer distributed application model. The application logic is divided into components by function, and each application component is distributed on different machines according to their layer. In fact, Sun designed J2EE to solve the disadvantages of the two-layer mode (Client/Server). In the traditional mode, the client plays too many roles and is bloated. In this mode, the first deployment is relatively easy, but it is difficult to upgrade or improve, and the scalability is not ideal. It is often based on a proprietary protocol-usually a database protocol. It makes it very difficult to reuse business logic and interface logic. The multi-tier enterprise application model of J2EE divides different layers of the two-tier model into multiple layers. A multi-tier application can provide an independent layer for different services. The following is a typical layer-4 Structure of J2EE:

Customer layer components running on client machines
Web layer components running on the J2EE Server
Business logic layer components running on the J2EE Server
Enterprise information system layer software running on the EIS Server

J2EE application components

A J2EE application is composed of components. J2EE components are software units with independent functions. They are assembled into J2EE applications through related classes and files and interact with other components. The following J2EE components are defined in the J2EE specification:

The application client and applets are customer-layer components.
Java Servlet and JavaServer Pages (JSP) are web layer components.
Enterprise JavaBeans (EJB) is a service layer component.
Customer layer components
J2EE applications can be web-based or traditional. The web layer component J2EE Web layer component can be a JSP page or Servlets. According to J2EE specifications, static html pages and applets are not web layer components. The web layer may contain some JavaBean objects to process user input and send the input to the enterprise Bean running on the business layer for processing.

Business Layer Components
The logic of the business-layer code is used to meet the needs of special business fields such as banking, retail, and finance. It is processed by enterprise beans running on the business layer. There are three enterprise-level beans: session beans, entity beans, and message-driven beans. Session Bean indicates temporary interaction with the client program. After the client program is executed, the Session Bean and related data will disappear. On the contrary, the Entity Bean represents a permanent record in a database table. When the client program is terminated or the server is shut down, there will be potential services to ensure that the data of the entity bean can be saved. The message-driven bean combines the characteristics of the Session Bean and the message listener of JMS, allowing a service layer component to receive JMS messages asynchronously.

Enterprise information system layer

The enterprise information system layer processes enterprise information system software, including enterprise infrastructure systems such as enterprise resource planning (ERP), mainframe transaction processing, database systems, and other legacy information systems. For example, the J2EE application component may need to access the enterprise information system for database connection.

Iv. J2EE Structure

This component-based, platform-independent J2EE structure makes the compilation of J2EE programs very simple, because the business logic is encapsulated into reusable components, the J2EE server provides background services for all component types in the form of containers. Because you do not need to develop such services on your own, you can concentrate on solving business problems at hand.

Containers and services

Container settings customize the internal support provided by the J2EE server, including security, transaction management, JNDI (Java Naming and Directory Interface) Addressing, remote connection, and other services, the following lists the most important services:

The J2EE Security model allows you to configure Web components or enterprise beans so that only authorized users can access system resources. Each customer belongs to a special role, and each role can only activate a specific method. You should declare the role and the method that can be activated in the layout description of enterprise Bean. Because of this declarative method, you do not have to write security-enhancing rules.

The J2EE transaction management model allows you to specify the relationship between all methods in a transaction, so that all methods in a transaction are treated as a single unit. When the client activates a method in an enterprise Bean, the container is involved in a management transaction. Because there are container management transactions, you do not have to encode the transaction boundary in the enterprise Bean. Code that requires control of distributed transactions is complex. You only need to declare the transaction attributes of the enterprise Bean in the layout description file, instead of writing and debugging complex code. The container will read this file and process the transactions for this enterprise Bean for you.

The JNDI Lookup service provides a unified interface for multiple enterprise names and directory services, so that application components can access the name and directory services. J2EE remote client connectivity (remote client connectivity) model management client and enterprise Bean. After an enterprise Bean is created, a client can call it as if it were on the same virtual machine as the client. Life Cycle Management Model manages the creation and removal of Enterprise beans. An enterprise Bean will go through several statuses during its life cycle. The container creates an enterprise Bean, moves it in the available instance pool and activity status, and finally removes it from the container. Even if you can call the create and remove methods of enterprise Bean, the container will execute these tasks in the background.

The database connection pool (pooling) model is a valuable resource. Getting database connections is a time-consuming task, and the number of connections is very limited. Containers mitigate these problems by managing the connection pool. Enterprise bean can quickly obtain connections from the pool. When the bean releases the connection, it can be used by other beans.

V. Container Type

The J2EE application components can be installed and deployed in the following containers:

The EJB container manages the execution of enterprise-level beans in all J2EE applications. Enterprise beans and their containers run on the J2EE server. Web containers manage the execution of JSP pages and Servlet components in all J2EE applications. Web components and their containers run on the J2EE server.

The application client container manages the execution of all application client components in J2EE applications. Application clients and their containers run on the J2EE server. The applet container is a combination of Web browsers and Java Plug-ins running on client machines.

Vi. Core APIs and components of J2EE

The J2EE platform consists of a complete set of services, application interfaces (APIS), and Protocols. It provides Function Support for developing web-based multi-layer applications, the following is a brief description of the 13 technical specifications in J2EE (limited by space ):

1. JDBC (Java database connectivity ):

JDBC APIs provide a unified way to access different databases. Like ODBC, JDBC shields developers from some details. In addition, jdcb's access to the database is also platform-independent. 2. JNDI (Java name and Directory Interface ):

The jndi api is used to run the name and directory services. It provides consistent models to access and operate enterprise-level resources, such as DNS and LDAP, local file systems, or objects on application servers.

3. EJB (Enterprise JavaBean ):

One of the reasons why J2EE technology has won widespread attention is EJB. They provide a framework for developing and implementing distributed business logic, significantly simplifying the development of scalable and highly complex enterprise-level applications. The EJB specification defines when and how the EJB component interacts with their containers. Containers are responsible for providing public services, such as directory services, transaction management, security, resource buffer pools, and fault tolerance. However, it is worth noting that EJB is not the only way to implement J2EE. Due to the openness of J2EE, some vendors can achieve the same purpose in parallel with EJB.

4. RMI (Remote Method invoke ):

As its name indicates, the RMI protocol calls methods on remote objects. It uses serialization to transmit data on the client and server. RMI is a more underlying protocol used by EJB. 5. Java IDL/CORBA:

With the support of Java IDL, developers can integrate Java and CORBA. They can create Java objects and expand them in corba orb, or they can also create Java classes and serve as the customers of the CORBA objects expanded with other orb. The latter method provides another way through which Java can be used to integrate your new applications with old systems.

6. jsp (Java Server Pages ):

A JSP page consists of HTML code and Java code embedded in it. The server processes the Java code after the page is requested by the client, and then returns the generated HTML page to the browser of the client.

7. Java Servlet:

Servlet is a small Java program that extends the functions of web servers. As a server-side application, it is executed when requested, which is similar to cgi Perl script. Most of the functions provided by Servlet are similar to those provided by JSP, but the implementation methods are different. JSP usually embeds a small amount of Java code in most HTML code, while servlets is all written in Java and generates HTML.

8. XML (Extensible Markup Language ):

XML is a language that can be used to define other Markup languages. It is used to share data in different business processes. The development of XML and Java are mutually independent. However, the same objective of XML and Java is platform independence. By combining Java and XML, you can get a perfect platform-independent solution.

9. JMS (Java Message Service ):

Ms is an application interface (API) used to communicate with message-oriented middleware ). It supports point-to-point domains, publish/subscribe domains, and supports the following types: Approved message transmission and transactional message transmission, supports consistent messages and persistent subscribers. JMS also provides another way to integrate your application with the old background system.

10. JTA (Java transaction architecture ):

JTA defines a standard API, which allows the application system to access various transaction monitoring data.

11. JTs (Java Transaction Service ):

JTs is the basic implementation of the transaction monitoring function of CORBA ots. JTs specifies the implementation method of the Transaction Manager. The transaction manager is a Java image that supports the Java transaction API (JTA) specification at the high-level level and implements omg ots specification at a lower level. JTs Transaction Manager provides transaction services for application servers, resource managers, independent applications, and communication resource managers.

12. javamail:

Javamail is an API used to access the mail server. It provides a set of abstract classes for the mail server. Not only supports SMTP servers, but also supports IMAP servers.

13. JTA (JavaBeans activation framework ):

Javamail uses JAF to process MIME-encoded email attachments.

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.