J2EE Blueprint Summary (ZZ)

xiaoxiao2021-03-06  17

J2EE blueprint Abstract J2EE TM Blueprints Digest Author: Monica Pawlan translation: Universal Linkage Development Group (Global Empower Inc.) If you have installed the J2EE TM Platform (Enterprise Edition) software, and read through the various guides available to help you learn to use The software, then you may have prepared to start writing the first multi-layer enterprise application for the J2EE platform. At this time, you may have the application design, and how to determine which J2EE API is most satisfying your requirements. You can get help. "Designing Enterprise Applications for the Java TM 2 Platform, Enterprise Edition ISBN 0-201-70277-0 describes a J2EE platform and proposes a programming model that can help you The best decisions are made for the J2EE platform to design multi-storey enterprise applications. For the theoretical contact, Chapter 10, an example of an e-commerce pet store application, describing how the programming model guides the design. This book and the Pet Store Application is called J2EE BluePrints (J2EE Blueprint). This article is a summary of the J2EE blueprint to introduce you to the programming model and help you master it. You can access the J2EE download page, download the book's PostScript or PDF Format version, or a pet store application as an example in the book. This book printing will be listed in July 2000. ˙J2ee Basic Architecture: Overview (J2EE Architecture -A Bird's-Eye View) ˙ Reuse Application Components (Reusable Application Components) Design User Interface and Engine (Designing Web-based Applications) ˙SERVLETS and JSP Pages (Servlets and JSP Pages) ˙ model, view, controller Design Paradigm (MODEL, VIEW, Controller Design Pattern) ˙J2EE Application ˙ Pet Store Application J2EE Basic Architecture: Overview Basic Architecture: Overview Basic Architecture: Overview Basic Architecture : Overview The rapid development of e-commerce and information technology and its needs bring new pressures to applications developers. Establish and manufacture companies must be designed, established, establish and manufacture than earlier than previous money. Application. In order to reduce costs, and speed up the design and development of enterprise applications, the J2EE platform provides a component-based approach to design, develop, assemble, and deploy enterprise applications. J2EE platform provides multi-layer distributed applications Models, components reuse, unintended security models, and flexible transaction control. You can not only To launch a creative customer solution than the previous faster speed, and your platform is independent, component-based J2EE solutions are not bound on any manufacturer's products and API.

The J2EE specification defines the following types: ˙ Application Client Components (Application Client Components) ˙enterprise JavaBeans TM Components ˙SERVLETS and JavaServer Pages TM (JSP page) Components (also known as web components) Servlets and JavaServer PagestM (JSP pages) Components) ˙applets A multi-layer distributed application model means that application logic is divided into components based on the function, and can be installed on the same server or different servers to make these J2EE applications Different components. An application component should be installed where, depending on which layer of the application component belongs to the multi-layer J2EE environment. These layers are customer layer, web layer, business layer, and enterprise information system layer (EIS). Client Tier J2EE application can be web-based or not web-based. In a web-based J2EE application, the user's browser is running in the client layer and downloads a static HTML page in the web layer on a web server or a dynamic HTML page generated by JSP or Servlets. In a non-web-based J2EE application, a standalone client, or not running in an HTML page, but running in other network-based systems (such as handheld devices or car phones) in customers The layers are running and access Enterprise Beans without the WEB layer. This non-Web-based client may also include a JavaBeans class to manage user input and send the input to the Enterprise Bean class running in the corporate level. According to J2EE specification, the JavaBeans class is not considered as components. The Javabeans class written for the J2EE platform has an instance variable and "GET and SET Method" for accessing data in the instance variable. The JavaBeans class used in this way is usually simple in design and implementation, but they must comply with the naming and design conventions listed in the Javabeans specification. The web layer J2EE Web component can consist of a JSP page, web-based Applets, and Servlets that displays the HTML page. The HTML page calling servlets or JSP pages is packaged with the web component when the application is assembled. Like a client, the Web layer may include a Javabeans class to manage user input and send input to the Enterprise Beans class running in the business layer. The web component running in the client layer relies on the container to support such as a customer request and response and an Enterprise Bean query. The business code is executed as a logic that solves or meets the needs of a particular business area (such as bank, retail or financial industry) is executed by Enterprise Beans running in the business layer. A Enterprise Bean receives data from the client program, processes the data (if needed), and then sends the data to the enterprise information system layer storage. A Enterprise Bean also retrieves data from the store and sends the data back to the client. Enterprise Beans running on the business layer depends on the container to provide a very complex system-level code such as transaction, life, state management, multi-threading, and resource storage pools. The business layer is often referred to as an Enterprise JavaBeans (EJB) layer.

The business layer and the web layer together constitute the intermediate layer of the 3rd floor J2EE application, while the other two layers are the client-level and corporate information system layer. Enterprise information system layer enterprise information system layer run enterprise information system software, including enterprise infrastructure system For example, a corporate resource plan (ERP), mainframe transactionProcessing, database system and other legacy information systems (Legacy Informationsystems). J2EE Application Components may require access to enterprise information systems for some reason (such as access database). The future versions of the J2EE platform will support the Connector architecture that connects the J2EE platform to a standard API on the enterprise information system. The QueuP Services is running separately because the components of a J2EE application are running separately and often run on different devices, there is a way to get a client layer and a web layer code to query and reference other code and resources. The client layer and the web layer code use the Java Name and Directory Interface (JNDI) to query user-defined objects, such as Enterprise Beans, environmental entries (such as a database drive position), JDBC TM for finding resources in the enterprise information system layer DataSource objects, and message connections. Security and Transaction Management, such as security and transaction management, such as security and transaction management, can be configured on the Web and Enterprise Bean components at the time of deployment. This feature separates the application logic from the configuration setting that may change. The secure J2EE security model allows you to configure a web or Enterprise Bean component that allows system resources to be accessed by authorized users. For example, a web component can be configured to prompt enter a username and password. An Enterprise Bean component can be configured to only call members in a particular community to call them. Alternatively, a servlet component can be configured to enable everyone in an organization to access certain methods while just access some of the privileges in the organization. Also, the servlet component can be configured for another environment to enable everyone to access all of them, or only the selected minorities access all of them. Transaction Management The J2EE transaction model enables the relationship between methods that make up a single transaction to define a single transaction time to define a single transaction to be processed into a single unit. This is what we want, because a business is a series of steps, all of which are all done, or all cancel. For example, an Enterprise Bean may have a group of methods that allow us to transfer money from the first account to the second account by borrowing and depositing the second account from the first account. We hope that all operations are treated as a unit, so that if it is faulty before the borrowing is deposited, the lending operation is canceled. Transaction attributes are defined on one component during assembly. This makes it possible to return a method from multiple application components to a transaction, which shows that we can easily change the application components in a J2EE application and re-specify transaction properties without having to change the code or recompile. When designing an application component, you have to remember that although Enterprise Beans has a mechanism that automatically initiates multi-step transactions, applets and applications may not support this. However, applets and application customer containers can always call an Enterprise Bean that supports this.

It should also be noted that JSP pages and servlets are not designed to be transactions, they should usually hand over transaction to an Enterprise Bean to complete. However, if the business is required in a JSP page or a servlet, then this kind of work should also be very limited. Re-use Application Components J2EE Components (Applets, Applications, Enterprise Beans, JSP Pages, and Servlets) are all packaged into modules and delivered as a Java Archive (JAR) file. A module consists of related components, related files, and describes how to configure components. For example, in the assembly process, an HTML page and the servlet are packaged in a module, which contains the HTML file, servlet component, and related configuration description files, delivered in the form of a Web Archive (WAR) file. The WAR file is a standard JAR file with a .war extension. Using modules make it possible to assemble different J2EE applications using certain components in the same components. For example, a J2EE application's Web version may have an Enterprise Bean component, as well as a JSP page component. The Enterprise Bean component can be combined with an application client component to generate non-Web versions of the application. This doesn't need additional coding, just an assembly and deployment. Moreover, the reuse component makes it possible to divide the application development and deployment process into different characters, such different people or companies can complete different parts of the package and deployment process. The J2EE platform defines the following roles: J2EE Product Provider design and makes J2EE platforms, APIs, and other features defined in the J2EE specification can be purchased by other companies or people. Application Components (Application Component Provider) Creates a Web component, Enterprise Bean component, applets, or a company or individual applying a client. During assembly, apply component files, interfaces, and classes to be packaged into a JAR file. Application Assembler Gets an Application Component JAR file from the component provider and assembles them into a company or individual of the Enterprise Archive (EAR) file for J2EE. This file is a standard with a .ser extension. file. Application assemblaborators provide the overall information related to the application and use the verification tool to verify the contents of the EAR file. Assembly and deployment information stores in a text-based configuration description file, this file uses an XML tag to mark the text. Application assemblists can edit the configuration description file directly according to the description of Chapter 7, "Design Enterprise Application", or use a assembly and configuration tool that can properly add an XML tag by interactive selection to edit the configuration description file. Deployer deploys companies or individuals of J2EE applications. Responsibilities include setting transaction control, security properties, and indicating that an Enterprise Bean is handling its own storage according to the instructions provided by the application component provider, or by a container. Deployment involves configuration and installation. During the configuration, deployers follow the instructions provided by the application component provider to solve external dependence issues, define security settings, and assign transaction properties. During the installation process, the deployment installs the application component to the server and generates a specific class and interface of the container.

System Administrator configures and manages computing environment and network infrastructure running J2EE applications, and supervises staff of the runtime environment. Tool Provider produces companies or individuals that are used by components providers, assembers, and deployers for development, assembling, and packaging tools. Design User Interface and Engine (Designing The User Interface and Engine) When designing a user interface and a backend engine for a J2EE application, we need to decide whether the program is based on the web or not based on the web. When making this decision, we may want to consider platform configuration, download speed, security, network traffic, and network services. For example, an applet containing a user interface and is often accessed by a large number of users may take a long time to be downloaded, which makes users depressed. However, if you know that the applet is to run in a controlled environment in a company's internal network, then in this case, the applet will have a fully acceptable download speed. Another consideration is that wherever the heavy processing should be executed. For example, if the client executes in a cellular phone or player, the server should complete as much as possible calculations and data processing, and the client program should only display the result. However, large financial analysis systems that are designed to run on a powerful desktop platform should complete their complex calculations on the client. Applying client programs and Applet user interfaces are usually created with Swing API, which is available from the standard version Java2 platform (Java 2 Platform, STANDARD Edition). The Swing API provides a set of GUI components (tables, tree structures, buttons, etc.) that can be used to implement a more interactive experience than using a typical HTML page. Swing also supports HTML text components, which can be used to display responses from one server. The client can access the Enterprise Bean layer or the enterprise information system layer. But this procedure should be realized with caution. The process bypassing the EJB layer can use the JDBC API to access a relational database, but should be restricted to maintain such administrative tasks for maintenance of the database table. Design web-based applications-based applications based on browser, and if they run on the Internet, they may be accessed by people around the world. When designing a web-based application, not only do you need to decide what to use to handle content and application logic (HTML, XML, JSP page, and servlets), but also should consider internationalizing the application. An internationally web-based application provides users with a language that loads the application of the application based on the selected language. For each language that is supported, the application body is stored in an external file and corresponds to the keywords of another file. Application code uses these keywords and selected languages ​​to load the correct text. Internationalization API also provides classes to format dates and money according to selected languages. Once the details of the internationalization of the application are developed, we can decide what to use to implement it. Overall, a web-based application uses HTML to display data; use XML to define data to make it read and processed by another program; use JSP pages or servlets to manage the user and business layer or storage Data flow. There are four kinds of web-based applications that can be implemented on the J2EE platform.

From simple to complex arrangements, they are: ˙ Basic HTML Tong Basic JSP page or servlets HTML ˙˙ JSP page with JavaBean class ˙˙ Apply logic according to the highly structured application of the functional score into the region is designed as a web-based application When the program needs to decide to create it. Also, if we start to start from the establishment of a simple application, if we think that it will add functions to the application later, the design should adapt to future development needs. The following content helps us make some design decisions by comparing JSP pages and servlets. Servlets and JSP Page Servlets are a simple, platform independent, web server independent way to realize dynamic content. The JSP page is a text-based and centered manner that develops servlets. The JSP page provides all the benefits of servlets, and when combined with a Javabeans class, a simple way to separate the content and display logic is provided. The advantage of separating content and display logic is that the person who updates the page appearance does not have to know the Java code, and the person who updates the JavaBeans class does not have to be a designed web page. JSP pages and servlets are more desirable than the public gateway interface (CGI), because CGI is not standing independent, using more system overhead, and there is no simple method to access parameter data, and send these data to a program. You can define the Web template with JSP pages with JavaBeans classes to create a website consisting of a similar appearance page. The JavaBeans class completes the data, so there is no Java code in the template, which means that these templates can be maintained by an HTML writer. When choosing a servlet, or a JSP page, you have to remember that servlets is a programming tool that best applies to low-level application features that do not require frequent modification; and JSP pages taken by display-centric descriptive The method combines dynamic content and logic. For a simple web-based application using a JSP page, we can use custom tags or scripTlets instead of using the JavaBeans class to combine content with application logic. Customized tags are packaged into a tag library and are introduced into a JSP page. ScriptleTs is a small Java code segment directly embedded in the JSP page. Models, View, Controller Architecture (MODEL, View, Controller Architecture) In the case of a component-based J2EE platform, the remaining issues may organize applications to implement simple and efficient application upgrades and maintenance And how to avoid procedures that you don't understand the program code. The answer is in the use of models, views, and control architecture (MVC). The architecture such as MVC is a description of the problem and its solution design, but the problem is not exactly the same time, the solution is not exactly the same. The MVC design paradigm includes three objects: Model provides application business logic (Enterprise Bean class); view (view) is displayed on the screen (HTML page, JSP page, Swing GUI); controller is servlet , JavaBean or Session Bean class, which is used to manage the interaction of users and views. We can imagine the controller between view and data, and manage how the view interacts with the model. The front-end client can be easily replaced by making the view completely independent of the controller and model.

Also, by maintaining the controller and the model code in the view, those who don't understand these codes cannot change what they should not change. Separating the controller and model can change the controller without affecting the model, or the model can be changed without affecting the controller. For example, if the front end of the application is an HTML page, an HTML expert can update it. If you use a JSP page, place the controller's code in a JavaBean or session bean class, or use the action tags, so that the JSP page contains only JSP code. ENTERPRISE Beans in applications in applications in J2EE applications When writing J2EE applications for administrative specific business features (such as tracking employee materials or complex financial calculations), will complete the business logic of these tasks. Place in Enterprise Beans in the EJB layer. In this way, we can make your code to solve your business problems, and use Enterprise Bean containers to support low-level services, such as status management, transaction management, thread management, remote data access, and security. Separating business logic with low-level system means that the container can create and manage Enterprise Beans at runtime. Any Enterprise Bean written in accordance with the specification can be configured in accordance with how they will be used in a specific J2EE application, and can be deployed to any container compatible with specifications. Re-use components make it possible without having to change and recompile Enterprise Bean code. An Enterprise Bean consists of an interface and class. The client will access the Enterprise Bean through the Home and Remote Interface of Enterprise Bean. The HOME interface provides methods for creating, deleting, and locating Enterprise Beans, while remote interfaces provide business methods. At deployment, the container is created by these interfaces to enable customers to create, delete, locate, or call business methods located on Enterprise Beans. The Enterprise Bean class provides business methods, creating methods, and implementation of the search method. If Enterprise Bean manages its own persistence, it also provides its life. There are two Enterprise Beans: Entity Beans and Session Beans. A session bean represents a short session with the client program, and may perform database read and write operations. A session bean may call JDBC yourself, or it may use Entity Beans to complete this call. In this case, this session bean is the customer of the Entity Bean. A session bean domain contains a session state and is short. If the server or client crashes, the session bean is lost. This mode is usually used on database programming languages ​​like PL / SQL. An Entity Bean represents data in a database and a method acting on the data. In the employee information table in a relational database, each line has a bean to represent. Entity Beans is transaction and is long life. As long as the data is left in the database, the Entity Bean exists. This mode can be easily used for relational databases, not limited to object databases. The session beans may be stateful or stateless. A stateful session bean contains a session status representative of the client. This session state is the domain value of the session bean instance plus all objects referenced by these domain values. There is a status session beans that does not represent data in a persistent data store, but it can represent and update data on behalf of the client.

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

New Post(0)