[Java Diary] Based on J2EE-based three-layer B / S information system author's cool moon palace master Posted on 2004-11-25 1:42:36
Abstract: With the continuous development of the Internet and software development structure, there is currently a more popular B / S structure, and there are a variety of solutions in achieving B / S structures. However, with the emergence of multi-platform applications, J2EE becomes the most popular enterprise solutions. This article describes the implementation of J2EE solution in actual enterprise applications in connection with practical applications, and compares with other distributed solutions. Key words: J2EE, B / S, three-layer structure, servlet With the increase in the size and complexity of the software system, the choice of software architecture is more important than data structures and algorithms, three-layer client / server The architecture provides a good framework for the integration of enterprise resource planning and is the best choice for establishing an enterprise management information system. With the development of the architecture, the software framework structure is also continuously developed. At present, there are different solutions for the implementation of Java technology and .NET technology in multi-layer application structures, which have advantages and disadvantages, which are suitable for different sizes. The requirements of the system. This paper will combine the implementation of the telecommunications plan construction management information system, describe the architecture of the three-layer mode, introducing the distributed component technology of the application system based on the three-tier mode, and explains the application of the J2EE frame structure to implement the implementation method of the application system. I. Selection of system structure 1. Disadvantages of traditional two-layer C / S structure conventional two-layer client / server mode is more suitable for small size, fewer users, single database and in safe, fast network environments (such as local area networks) run. However, as the scale of the application system continues to expand, complexity is increasing in multi-user, multi-database and non-secure network environments (for example,: Internet), the application model of this two-layer structure will not be adapted. Moreover, the traditional two-layer structure has the following defects: (1) It is a single server and is centered on the LAN, so it is difficult to extend to large enterprise wide area network or intranet; (2) is limited by the supplier, the upgrade maintenance of the program must Suppliers re-development; (3) soft, hardware combination and integration ability limited; presenting fat clients on the software, users must install specific client applications on the client, and the business logic of the company is written in customers In the end application, the program maintenance is difficult, and the program upgrade requires every client to install a new client application. At the same time, for the program developer, the reuse of the program module is relatively independent; (4) c / S mode is difficult to manage a large number of clients. Based on the above reasons, the traditional C / S mode has not adapted to development needs. With the popularity of network technology and the further improvement of user demand, the three-layer Web mode came into being. 2, the advantages of the three-layer Web structure Three-layer client / server mode (hereinafter referred to as three-layer mode) increases the new level based on two layers of mode. This model is logically divided into three layers: customer display layer, business logic layer, data layer. The customer display layer is a graphical interface that provides the application service to help users understand and efficient location application services. The business logic layer is located between the display layer and the data layer, providing a clear level specifically for realizing the business logic of the company, encapsulating the application model associated with the system in this level, and separates the user to the database code. This level provides contact between client applications and data services. The main feature is to perform application policies and package application modes, and present the packaged mode to the client application. The data layer is the bottom layer in the three-layer mode, and he is used to define, maintain, access, and update data and manage and meet the application service request. The main advantages of the three-layer mode are: 1 Good flexibility and scalability. For the case where the environment and application conditions are often changed, the purpose can be achieved as long as the corresponding change is performed on the application layer. 2 shareability. A single application server can provide services to client applications in different platforms, which save development time and capital investment; 3 better security.
In this configuration, the client application cannot directly access the data, but the application server can control which data can be controlled and accessed, but also control data change and access. 4 Enhance the repetitive availability of corporate objects. "Business Object" means an object that encapsulates the logical program code and can perform a specific function. With the development of component technology, this reusable component pattern is increasingly accepted by software development. 5 Three-layer mode becomes a "thin client" in the true sense, there is high stability, ductility, and execution calibration. 6 The three-layer mode can be managed together to manage the service, unify the client, thereby has good fault tolerance and load balancing capabilities. The three-layer architecture telecommunications planning construction management information system is a unified management of subordinate telecommunications companies, all business logic is concentrated in the management and development of provincial companies, and the management of data is subject to data entry and query statistics, users A wide range of distribution, data concentration, so it is necessary to take advantage of the advantages and disadvantages of various architectures when designing, and selects three-layer web mode for development implementation. Second, the selection of the architecture 1. DCOM distributed technology and CORBA distributed technology Microsoft's distributed COM (DCOM) technology is to expand the development of object model technology COM, which is the computer object on the LAN, WAN, and even the Internet. Communication provides full support. By using a DCOM user, you can achieve true distribution at any network location, thereby meeting the needs of customer applications. The overall structure is as shown below: The public object proposed by OMG Request Agent CORBA object is a common type of intermediate specification, which is also a component implementation specification. The main goal is to make the object reuse in a distributed environment. Transplantation and interoperability, the overall structure of CORBA is shown below: The above two distributed structures can be implemented in a unified specific environment, and the implementation of the local area network is more popular, but for different platforms and Internet Application, the two lack flexibility. 2, J2EE architecture introduction J2EE architecture is divided into three levels, namely customer representation, intermediate logic and data management and application systems. This structure has a cross-platform characteristic, three hierarchicals in the structure can be in different platforms; because the customer represents a different client program, there is a good distribution, which can accommodate distributed management. Requirements; in the background application system integration, the enterprise can be integrated into this structure, so that the existing resources can not be damaged. The core framework of the web service implemented based on J2EE is shown below: WEB services developed with J2EE-based architecture also have the following advantages: 1 can communicate across the intermediate firewall. Because the web service uses HTTP's most transported media, the intermediate layer uses web services, you can call the intermediate layer component directly from the customer interface without having to create a page. 2 Integration of application systems. It is necessary to integrate a lot of developments that are written in different languages in different languages. The standard method can be exposed using a standard approach to use in other programs. 3 All corporate logic and services are integrated into reused, portable EJB components, so system maintenance and reusability. 4 Middleware code can be concentrated on processing business logically without considering data representation. Because the business logic and data processing rules of this telecommunications plan construction management information system are all managed by the group companies and provincial companies, data and procedures are concentrated in unified servers, and the server running platform is different from the client's running platform, so The frame structure of J2EE is solved is suitable.
Third, the system design and implementation passes the application of Java technology as the application technology of this system design, and our design of the system is as follows: The front desk user display layer implements JSP and servlets on the browser In the middle, use the EJB component to implement corporate business logic, the background database uses the Sybase database. The specific enterprise application structure is as follows: where the middleware uses the BEA's WebLogic 7.0, the development tool uses JBuilder9.0, the database uses the Sybase database. During the user login process, because users used throughout the client are more, we use the connection pool to process. Particular connection pool to achieve the following: class DBConnectionPool {public DBConnectionPool (String name, String URL, String user, String password) {this.name = name; this.URL = URL; this.user = user; this.password = password; this.maxConn = maxConn;} private void createPools (Properties props) {private Hashtable pools = new Hashtable (); String poolName = props.getProperty ( "poolname") trim ();. String url = props.getProperty (poolName ". url ".) trim (); String user = props.getProperty (poolName " .user "); String password = props.getProperty (poolName " .password "); String maxconn = props.getProperty (poolName " .maxconn "," 0 "); int Max; dbconnectionpool pool = new dbconnectionpool (poolname, url, user, password); utility.log (pool.tostring ()); pools.put (poolname, pool); utility.log (" Successfully created connection pool " poolname);}} In order to use sessionBean to log in to confirmation processing, use the bean's listening function to listen to the user's login time, more time, automatically cut off the user login connection, let the user re-login. In the application system, the permissions after the user login is a key. In the process of using the J2EE frame structure, use the Servlet filtering function to implement permissions, the specific implementation structure is as follows: The definition of the filter is as follows: < Web-app>