EJB programming and J2EE system architecture and design

zhaozj2021-02-16  136

(Loaded from http://www.javaresearch.org/Article/showArticle.jsp?column=2&thread=7236)1, introducing the Java 2 platform has three versions: They are the Java 2 platform for small devices and smart cards Micro version ( Java 2 Platform Micro Edition, J2ME, Java 2 Platform Standard Edition, J4SE, is available on the desktop system, and Java 2 Platform for Creating Server applications and services (Java 2 Platform Enterprise Edition, J2EE). The most important of these is the J2EE platform. J2EE is an architecture using Java 2 platform to simplify the development, deployment, and management of business solutions. The basis of J2EE technology is the standard version of the core Java platform or Java 2 platform. J2EE not only consolidates many of the advantages in the standard version, such as "writing once, run everywhere", which is easy to access the JDBC API, CORBA technology, and capable of accessing the database. Safety mode for protecting data in the Internet application, etc., and also provides comprehensive support for EJB (Enterprise JavaBeans, Java Server Pages), and XML technology. The ultimate goal is to be an architecture that enables enterprise developers to significantly shorten the market time. The J2EE architecture provides an intermediate-level integrated framework to meet the needs of applications that do not require too much cost and require high availability, high reliability, and scalability. By providing a unified development platform, J2EE reduces the cost and complexity of developing multi-layer applications, while providing strong support for existing applications, fully supporting Enterprise JavaBeans, with good guidance support packaging and deployment applications, add directory support , Enhance the safety mechanism and improve performance. J2EE provides a good mechanism for building a scalability, flexibility, and easy-to-maintain business system: reserved existing IT assets: Since companies must adapt to new business needs, using existing corporate information systems investment, It is also important to re-establish a total plan. Thus, a server-side platform mechanism established on an existing system in a progressive (rather than radical, all) is the company's needs. The J2EE architecture makes full use of the original investment, such as the BEA Tuxedo, IBM CICS, IBM Encina, Inprise Visibroker, and Netscape Application Server used by some companies. This has become possible because J2EE has a wide range of industry support and some important 'enterprise calculation' domain suppliers' participation. Every vendor provides an existing customer's upgrade route for existing investments and enters the portable J2EE field. Since products based on J2EE platforms can almost operate on any operating system and hardware configuration, existing operating systems and hardware can be reserved. Efficient development: J2EE allows companies to hand over some general, cumbersome server tasks to middleware suppliers. This developers can concentrate on how to create business logic, reduce development time accordingly. Advanced Middleware Suppliers offer the following complex middleware services: Status Management Services - Let developers write less code, do not care about how to manage status, this can be done faster. Continuous Services - Let developers can write applications without encoding data access logic, can generate more lightweight, unrelated to the database, which is easier to develop and maintain. Distributed Shared Data Objects Cache Services - Make developers to prepare high-performance systems, greatly improve overall deployment of scalability.

Support heterogeneous environments: J2EE can develop portable procedures deployed in heterogeneous environments. J2EE-based applications do not rely on any particular operating system, middleware, hardware. Therefore, a reasonable J2EE-based program is designed to be deployed to a variety of platforms. This is critical in a typical heterogeneous enterprise computing environment. The J2EE standard also allows customers to order off-the-shelf components compatible with J2EE, deploy them into the heterogeneous environment, saving the costs required by themselves. Scalability: Enterprises must choose a server-side platform that provides excellent scalability to meet a large number of new customers who make business operations on their system. Applications based on J2EE platforms can be deployed on a variety of operating systems. For example, it can be deployed to high-end UNIX and mainframe systems, which can support 64 to 256 processors. (This is the supplier of the NT server) J2EE field provides a wider load balancing strategy. Can eliminate bottlenecks in the system to allow multiple servers integrated deployment. This deployment can reach thousands of processors, achieving highly scalable systems to meet future business applications. Stable availability: A server-side platform must be able to operate all-day to meet the needs of company customers, partners. Because Internet is global, there is everywhere, even if it is downtown at night, it may cause serious loss. If it is unexpected, there will be catastrophic consequences. J2EE deploys to a reliable operating environment that they support long-term availability. Some J2EE deployed in a Windows environment, customers can also choose a robust performance, such as Sun Solaris, IBM OS / 390. The most robust operating system can reach 99.999% availability or only 5 minutes a year. This is an ideal choice for real-time business systems. The J2EE platform based on hierarchical component mode is separated from business logic and underlying network technology, with scalability, scalability, easy development, and easy maintenance, have become the factual standard for enterprise-class commercial distributed network computing. J2EE is a large number of advanced, perfect, practical norms that have been designed in the industry's technical experts, educational experts collective wisdom and experience, and compliance with this standardized developer will get extensive support from the industry, making the development of enterprise-class applications simple, fast . Learning Java, it is not so much learning a technology, it is better to learn a programming idea, and the idea of ​​the J2EE system platform is to provide a unified standard for distributed applications through a component-based application model. 2, J2EE Introduction

2.1 J2EE Platform Specification (Java 2 Platform Enterprise Edition Platform Specification)

The J2EE platform specification is a component-based pattern defined by Sun Company to simplify distributed enterprise-level applications and deployments (The J2EE Platform Specification Defines A Component-Based Model That Simplifies Enterprise Development and deployment). It provides a multi-level distributed application model and a series of development technical specifications. Multi-level distributed application models are divided into multiple hierarchy, each level supports the corresponding server and components, and the components run in the component container of the distributed server (such as the servlet component runs on the servlet container, EJB components are The EJB container is running, and the container communicates between the containers, and the mutual call between components is implemented.

2.2 J2EE components and levels

J2EE uses multi-layered distributed application models, application logic is divided into components, and each application component is distributed in different machines based on their layers. In fact, the original intention of Sun Design J2EE is to solve the drawback of two layers (Client / Server), in traditional mode, the client acts as a large role and looks bloated, in this mode, the first deployment It is relatively easy, but it is difficult to upgrade or improve, the stretchability is not ideal, and often based on some proprietary protocol ?? is usually a database protocol. It makes it difficult to reuse business logic and interface logic. Now J2EE's multi-layer enterprise application model cuts different levels in the two-layer model into many layers. A multi-layer application can provide a separate layer for each of the services, as shown in Figure 1, the following is four hierarchicals and corresponding components of the J2EE specification: Figure 1 J2EE component and hierarchical four layers are running Client tier on the client machine, running on the web tier on the web server, running the business tier on the EJB server and the enterprise information system layer running on the EIS server (Enterprise Information system tier) The web layer and the business layer form the intermediate layer of the three-layer J2EE application, and the other two are the client layer and the storage layer or the enterprise information system layer. Under normal circumstances, many open companies are incorporated with the web server and EJB server products, called application servers or J2EE servers. The J2EE platform specification also defines the components of the corresponding layer: i. Client layer components Application client programs and browsers are client-side components. The client-side component can be a web-based web-based browser that is a web server, or a traditional (non-web-based) independent application can complete the task that the thin client cannot complete. II. Web Layer Components Java Servlet and JavaServer Pages (JSP) are web layer components. As the client layer shown in Figure 2, the web layer may contain some JavaBean objects to process user input, and send input to Enterprise beans running on the business layer. According to J2EE specification, static HTML pages and Applets are not a web layer component. The JavaBean and EJB (Enterprise Javabean) here have no relationships in the two component patterns in addition to the name of "Javabean". Many articles put EJB as the original "javabean" extension, which is wrong. EJB does not expand or use JavaBean component mode. The original JavaBean (Java.beans package) is used inside the process, and the EJB (Javax.ejb package) is the component used in the process (InterProcess). That is, the initial JavaBean is not set for distributed components. It is the best component mode, which may be the best process in the best process, but it is not a server-side component mode. EJB can solve problems that are brought by managing distributed business objects in the three-layer structure. Figure 2 Client layer, web layer and business layer III. Business layer components Enterprise JavaBeans (EJB) are business-layer components. The logic of business layer code is used to meet the needs of special business sectors such as banks, retail, and finance, and process it by EJB running on the business layer. Figure 3 shows how an EJB receives data from the client program, processes (if necessary), and is sent to the Enterprise Information System Layer (EIS) layer, which can also be reverse. There are three enterprise-class beans: session beans, entity (Entity), and message-driven beans.

The session bean means a temporary interaction with the client program. When the client program is executed, the session bean and related data will disappear. Instead, the entity bean represents a permanent record in the table of the database. When the client program is aborted or when the server is turned off, there is a potential service to ensure that the data of the entity bean is saved. Message Driver BEAN combines the characteristics of the message listener of session beans beans and JMS, allowing a business layer component to receive JMS messages asynchronous. Figure 3 Client layer, web layer, business layer and EIS layer IV. Enterprise information system layer components handling enterprise information system software includes enterprise infrastructure systems such as enterprise resource programs (ERP), large machine transaction, database systems, and others The legacy information system forms a corporate information system layer. For example, J2EE Applications may access enterprise information systems for database connections. 2.3 J2EE distributed application technology introduction

The J2EE platform consists of a set of services, application interface (APIs), and protocols that provide functional support for developing web-based multi-storey, distributed applications: (1) Component / container technology as shown in Figure 4 The J2EE structure having a platform-independent, which makes the J2EE program are very simple because the service logic is encapsulated into a reused component, and the J2EE server provides background service in the form of a container. Because you don't have to develop this service yourself, you can concentrate on solving your business problems. Figure 4 Component / Container Structure J2EE Application Components You can install deployment to the following containers: EJB container manages the execution of EJB in all J2EE applications. EJB and their containers are running on the J2EE server. Web container manages the execution of all JSP pages and servlet components in all J2EE applications. The web components and their containers are running on the J2EE server. Application Client Vault Manages Perform of Application Client Components in the J2EE application. The application client and their containers are running on the client machine. The AppleT container is a combination of web browsers and Java plugins running on the client machine. The container settings customize the intrinsic support provided by the J2EE server, including security, transaction management, Java Naming and Directory Interface Address, Remote Connection, etc. The following is the most important service: J2EE security (Security) model You can configure Web components or EJBs so that only authorized users can access system resources. Each customer belongs to a special role, and each role only allows a specific method to be activated. You should declare roles and can be activated in the arrangement of EJBs. Due to this declarative approach, you don't have to write rules that strengthen security. J2EE Transaction Management Model allows you to specify a relationship between all methods in a transaction, such a transaction is used as a single unit. When the client activates a method in an EJB, the container involves a management transaction. Due to the container management transaction, there is no need to encode the boundaries of the transaction in EJB. The code that requires controlling distributed transactions will be very complicated. You only need to declare the EJB transaction attribute in the arrangement description file without writing and debugging complex code. The container will read this file and handle this EJB transaction. JNDI Address (JNDI Lookup) provides a unified interface to multiple names and directory services within the enterprise, so application components can access names and directory services. J2EE Remote Connection (Remote Client Connectivity) model management client and the low-level interaction between the EJB. When an EJB is created, a client can call it, just like it and the client is located on the same virtual machine. Life cycle management (Life Cycle Management) model management EJB creation and removal, an EJB will have several states in its survival cycle. The container creates EJB and moves him in the available instance pool with the active state, and finally removes it from the container. Even if you can call EJB's Create and REMOVE methods, the container will also perform these tasks in the background. Database Connection Pooling model is a valuable resource. Getting a database connection is a time consuming, and the number of connections is very limited. The container is alleviated by managing the connection pool. EJB can quickly get a connection from the pool. Other EJBs can be used after the EJB release connection. (2) Servlets and JSPJSP (Java Server Pages): The JSP page is composed of HTML code and the Java code embedded in it. The server is processed after the page is requested by the client, and then returns the generated HTML page to the client's browser.

Java Servlet: Servlet is a small Java program that extends the functionality of the web server. As a server-side application, starting when the request is performed, which is similar to the CGI Perl script. Most of the functionality provided by servlet is similar to JSP, but the implementation is different. JSP is usually embedded in a small amount of Java code in most HTML code, while servlets are written by Java and generate HTML. (3) EJB technology EJB (Enterprise Javabean): J2EE technology Wins one of the reasons for some extensive attention is EJB. They provide a framework to develop and implement distributed business logic, which significantly simplifies the development of enterprise applications with scalability and highly complex. The EJB specification defines how EJB components interact with their containers. The container is responsible for providing public services, such as directory services, transaction management, security, resource buffer pools, and fault tolerance. But here is worth noting that EJB is not the only way to implement J2EE. It is because of the openness of J2EE, so that some vendors can achieve the same purpose in a way and EJB. (4) Database Access JDBC (Java Database Connectivity): JDBC API provides a unified way for accessing different databases, like ODBC, JDBC blocks some detail issues to developers, and JDCB access to the database also has Platform independence. (5) Distributed communication technology and distribution Application Technology JNDI (Java Name and Directory Interface): JNDI API is used to perform name and directory service. It provides a consistent model to access and operate enterprise resources such as DNS and LDAP, local file systems, or objects in the application server. RMI (Remote Method Invoke): As indicated by its name, the RMI protocol calls the remote object method. It uses a serialized manner to pass data on the client and server. RMI is a more underlying protocol used by EJB. RMI-IIOP: It provides an implementation of the usual Java Remote Method Invocation (Java Remote Method Call RMI) API on Internet Inter-ORB Protocol (IIOP). It races a bridge between the RMI and CORBA applications. This is a standard communication protocol used between J2EE containers. Java IDL / CORBA: With the support of Java IDL, developers can integrate Java and Corba. They can create Java objects and make it expanded in Corba ORB, or they can also create Java classes and customers who are expanded with other ORBs. The latter approach provides another way, through which Java can be used to integrate your new application and old system. JMS (Java Message Service): JMS is an Application Interface (API) for communicating with a message-oriented middleware. It supports the domain of point-to-point, with domains that support publish / subscribe / subside types, and provide support for the following types: approved messaging, transaction messages, consistent messages, and subscriptions with persistence Support. JMS also provides another way to integrate your application with the old background system. JTA (Java Transaction Architecture): JTA defines a standard API, which can be accessed by various transaction monitoring. JTS (Java Transaction Service): JTS is the basic implementation of CORBA OTS transaction monitoring. JTS specifies the implementation of the transaction manager. This transaction manager is a Java Transaction API (JTA) specification in the high-level, and implements the Java image of OMG OTS Specification at a lower layer.

JTS Transaction Manager provides transactional services for application servers, resource manager, independent app, and communication resource manager. JavaMail: JavaMail is an API for accessing a mail server, which provides an abstract class of a mail server. Not only supports SMTP servers, but also supports IMAP servers. JAF (JavaBeans Activation Framework): JavaMail uses JAF to handle MIME encoded mail attachments. MIME's byte stream can be converted to a Java object, or converted from Java objects. Most applications can use JAF directly. JAXP (Java API for XML PARING): This API provides an abstraction for the XML parser and API. JAXP can help implement specific XML parsers, XML Document Object Model or to convert XSLT into API and J2EE application code. JAVA Connector Architecture: This API has recently been included in J2EE, providing a way to integrate the J2EE application component into the old-style information system. Jaas (Java Authentication and Authorization Service): This API provides authentication and authorization mechanisms for J2EE applications. XML (Extensible Markup Language): XML is a language that can be used to define other tag language. It is used to share data in different business processes. The development of XML and Java are independent of each other, but it is the same objective as Java is platform independence. By combining Java and XML, you can get a perfect platform-independent solution. 3, the distributed application technology of J2EE platform

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

New Post(0)