CN1259623C - Structure method of five-hierarchical system structure base on J2EE - Google Patents

Structure method of five-hierarchical system structure base on J2EE Download PDF

Info

Publication number
CN1259623C
CN1259623C CN 200410014139 CN200410014139A CN1259623C CN 1259623 C CN1259623 C CN 1259623C CN 200410014139 CN200410014139 CN 200410014139 CN 200410014139 A CN200410014139 A CN 200410014139A CN 1259623 C CN1259623 C CN 1259623C
Authority
CN
China
Prior art keywords
layer
data
ean
entity
j2ee
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Expired - Fee Related
Application number
CN 200410014139
Other languages
Chinese (zh)
Other versions
CN1560741A (en
Inventor
史宇清
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Individual
Original Assignee
Individual
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Individual filed Critical Individual
Priority to CN 200410014139 priority Critical patent/CN1259623C/en
Publication of CN1560741A publication Critical patent/CN1560741A/en
Application granted granted Critical
Publication of CN1259623C publication Critical patent/CN1259623C/en
Anticipated expiration legal-status Critical
Expired - Fee Related legal-status Critical Current

Links

Landscapes

  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The present invention relates to a construction method based on a five-layer architecture of J2EE, and belongs to the technical field of the application of a distributed computer. The present invention provides and realizes a five-layer architecture conforming to the J2EE specifications. A data layer, a data integration layer, a business logic layer, an interface control layer and a user interface layer are constructed in the server from bottom to top. The structure of the application program is clear, the performance is good, and the application program is easy to realize. The present invention has the advantage that the safety is high; the consumption of network resources is decreased; the components are reused based on the industry standardization; developers without high programming technique can utilize the architecture to rapidly develop a distributed corporate application program with high efficiency, safety, reliability, flexibility and easy management.

Description

Five layer architecture construction methods based on J2EE
Technical field
The present invention relates to a kind of five layer architecture construction methods, belong to the distributed computer applied technical field based on J2EE.
Background technology
The J2EE of Sun (Java 2 Platform, Enterprise Edition, Java 2 platform, enterprise edition) is the multi-tier systematic structure of a standard, is applicable to the distributed enterprise application of develop and field, has following characteristics:
1, the J2EE technical manual is the center with the container.The J2EE container provides a kind of manageable running environment for the member that resides in wherein.Container also uses container A PI (Application Program Interfaces, application programming interface) to provide system-level service for the member that operates in the container simultaneously.
2, J2EE is one group of coordination standard, utilizes standardization, modular member to simplify enterprise application.Because member itself autonomy and the address-transparent that are had, therefore, just has the good advantage of manageability, reusability and retractility based on the application program of member.
3, J2EE supports clustering technique, and promptly in J2EE, container and member can be dispersed on a plurality of servers, owing to eliminated the fault of single point.Therefore the application program of J2EE has high availability and high reliability.
4, J2EE is based on Java language, therefore has the advantage that Java " once writes, everywhere operation ".
5, J2EE utilizes JAAS (Java Authentication Authorization Service, Java authentication vs. authorization API) provide Java to authorize and authentication service, add the security mechanism of Java language itself, for the J2EE application program provides security.
The latest edition of J2EE is J2EE1.4, and it supports JSP2.0 (Java Server Page), Servlet 2.4, EJB 2.1 (Enterprise JavaBean) and JDBC 2.0 API such as (JavaDatabase Connectivity).Here: JSP supports the self-control label; Servlet has obtained filtrator; JSP and Servlet are used to carry out the network structure exploitation.EJB has changed the persistence of Container Management, and the CMP (Container-ManagedPersistence, the persistence of Container Management) with local interface is provided entity B ean, and EJB is used for the business logic development member.JDBC (Java Database Connectivity, the Java database connects) provide and being connected of relevant database, provide simultaneously and connect buffering and distributed transaction, it and RMI (Remote Method Invocation, remote method invocation (RMI)) and JNDI (JavaNaming and Directory Interfaces, Java name and directory interface) constituted the J2EE technology of distributed development jointly.
Understand according to the applicant, existing J2EE application system has three layers, four layers or N layer structure usually.Wherein three layers is that application program is divided into: client layer (using HTML, Applet or Java Application and other CLIENT PROGRAM), middle layer (using JSP, Servlet or EJB) and resource layer (comprising database or original information system of enterprise).Its feature is: with the entity B ean among JSP, Servlet and the EJB, session Bean etc. separately or mix and be applied to the middle layer.Four layers is that the middle layer in three layers is divided into: Web layer (using JSP or Servlet) and operation layer (use EJB).Its feature is: with JSP and Servlet etc. separately or mix and be applied to the Web layer; With entity B ean among the EJB and session Bean etc. separately or mix and be applied to operation layer.The N layer is the various technology of J2EE to be intersected use, and makes application program comprise three layers, four layers or other various architectures.Understand according to the applicant, also do not have strictness to be divided into five layers architecture at present.More than the clear in structure that has of existing J2EE application program but performance not high (as three layers, four layers); The performance height that has but structure unclear (as the N layer).In general, used J2EE technology more complicated requires programmer that higher technical merit and art of programming are arranged, and system is difficult to realize, is difficult to multiplexing.
Summary of the invention
The technical problem to be solved in the present invention is: the problem at above prior art exists, a kind of five layer architecture construction methods based on J2EE are proposed, make application program have following characteristics based on J2EE: 1, clear in structure, superior performance, be easy to realization; 2, can implementation framework multiplexing; 3, can realize the exchanging visit of heterogeneous database; 4, have high security, can cross over fire wall and use on the Internet.
In order to solve above technical matters, the five layer architecture construction methods that the present invention is based on J2EE may further comprise the steps: on computer operating system
1), makes up data Layer---opening relationships type database, in order to the storage service data, for adjacent upper strata provides service.
2), make up the data set stratification---adopt Container Management persistence (Container Managed Persistence) entity B ean to set up the data set stratification of constructing on data Layer with local interface, a unit of the corresponding described database of each described entity B ean, in order to will sending database to session Bean data processed, and send the data in the database to session Bean by entity B ean.
3), make up Business Logic---adopt session Bean (state and stateless are arranged) to set up the Business Logic of constructing on the data set stratification with remote interface, be deployed in the same Java Virtual Machine in (Java Virtual Machine) with closely-related Container Management persistence entity B ean with as the session Bean packing of packing, in order to will sending entity B ean to the Servlet data processed, and will send Servlet to entity B ean data processed by session Bean.
4), make up the interface control layer---adopt servlet (Servlet) to set up the interface control layer of constructing on Business Logic, dynamic process network HTTP request, generate http response, processing controls stream and startup business operation, send user's data processed in the JSP page to session Bean with Servlet, and will send the JSP page to session Bean data processed.
5), make up the customer interface layer---adopt the java server page (Java Server Page) to set up the customer interface layer of constructing on the interface control layer, send user's operation to Servlet with the JSP page, and will send the user to the Servlet data processed.
The present invention proposes and has realized five layer architectures that meet the J2EE standard: promptly, to in server, build as shown in table 1, the bottom-up five-layer structure that is respectively data Layer, data set stratification, Business Logic, interface control layer and user interface layer.This architecture makes application structure clear, and superior performance and be easy to realize can realize component reusage simultaneously on the standardized basis of industry.The developer only need grasp with this architecture simple JSP, Servlet, session Bean and local interface CMP entity B ean programmed method and understand the distributed computer application program that XML language, JAAS, JNDI and JDBC just can develop superior performance fast.
Customer interface layer JSP
Interface control layer Servlet
Service logic layer conversation Bean (state and stateless are arranged)
The data set stratification has the CMP entity B ean of local interface
The data Layer relevant database
Table 1 is based on five layer architectures of J2EE
Particularly, the present invention separates the use of entity B ean among the EJB and session Bean, employing has the CMP entity B ean of local interface as the data set stratification, the data-switching of relevant database can be become object like this, and the remote client is hidden its object model; Owing to call the entity B ean with local interface by session Bean, feasible repeatedly data value to database calls and becomes object reference one time, reduces the consumption of Internet resources, improves system performance simultaneously.In addition, also the use with JSP and Servle separates, and handles representing of complicated interface with JSP; Servlet is responsible for responding user's request.As a result, will build five coating systems of clear in structure, each layer all represented specific function combinations.Bottom is by providing the interface support and only support adjacent upper strata, and the upper strata obtains and only obtain the service of adjacent bottom by calling interface, layer with layer between can not cross-call.
Generally speaking, five layer architectures of the present invention have following characteristics:
The data Layer of 1 system adopts relevant database; The use of entity B ean among the EJB and session Bean is separated:
2, the data set stratification of system adopts the CMP entity B ean with local interface, is realized services such as safety, transactional integrity, telecommunication and retractility automatically by Enterprise Java Bean container.A table in entity B ean correspondence database like this on the standardized basis of industry, also promptly after database structure standardization, standardization, can realize with entity B ean being the component reusage of unit at least.System utilizes entity B ean to send database to session Bean data processed; Conversely, system also utilizes entity B ean to send the data in the database to session Bean, that is, to any operation of database all must by and only undertaken by entity B ean.
3, the Business Logic of system adopts two kinds of session Bean with remote interface, is respectively: state session Bean and stateless session Bean are arranged.Adopt session Bean the repeatedly far call of direct access entity Bean can be become a far call that carries out with session Bean as the service logic layer assembly, promptly provide high-level abstractions to the client, provide the coarse grain visit to the business object that participates in the system, help alleviating network pressure like this, improve system performance.System utilizes session Bean to send entity B ean to the Servlet data processed; Conversely, system also utilizes session Bean to send Servlet to entity B ean data processed, that is, to entity B ean any call all must by and only undertaken by session Bean.
4, the interface control layer of system adopts Servlet, and Servlet is responsible for responding user's request, and according to user's behavior, decision sends to the user with which JSP page.Simultaneously, Servlet is the same with EJB to be the Class file that operates in server end, and the user is difficult to revise source program, can improve the security of system.System utilizes Servlet to send user's data processed in the JSP page to session Bean; Conversely, system also utilizes Servlet to send the JSP page to session Bean data processed, that is, to session Bean any call all must by and only undertaken by Servlet.
5, the user interface of system all adopts the JSP page, and JSP only is responsible for handling the interface and represents.The advantage of Chu Liing is like this: development can be divided the work, design static page by special art designing personnel.System utilizes the JSP page to send user's operation to Servlet; Conversely, system also utilizes the JSP page to send the user to the Servlet data processed, that is, to Servlet any call all must by and only undertaken by the JSP page.Simultaneously the user to any operation of system all must by and only undertaken by the JSP page.
In brief, with the application system of the present invention's five layer architectures exploitations, the user to the operation of database all must by and only undertaken by the mode of the JSP page → Servlet → session Bean (state or stateless are arranged) → have CMP entity B ean → database of local interface; Conversely, data from database submit to the user also must by and only undertaken by the mode of database → have CMP entity B ean → session Bean (state or stateless the are arranged) → Servlet → JSP page of local interface.The application system that employing realizes based on five layer architectures of J2EE, clear in structure, superior performance is easy to realize, can realize component reusage on the standardized basis of industry simultaneously.This architecture itself can also be carried out multiplexing as a framework in the exploitation of application program, makes the developer who does not have superb art of programming also can utilize this architecture to develop distributed enterprise application program efficiently fast
Embodiment
Embodiment one
Be that example describes method of the present invention in detail at first to make up towards the detailed process based on five layer architectures of J2EE in water conservancy field.
1, makes up data Layer
The bottom of J2EE standard is the enterprise information system layer, comprises enterprise infrastructure systems such as Enterprise Resources Planning, Database Systems, and multiple standards API such as JCA, JDBC.Because Sybase and oracle database are mainly adopted in the water conservancy field at present, therefore the application framework bottom towards the water conservancy field adopts relevant database.
JDBC in the J2EE container (Java Database Connectivity, the Java database connects) provide a common interface for application program is connected to relevant database.JDBC has platform-neutral to access of database, has solved the handling problem of heterogeneous database, thereby simplifies and accelerated performance history.Along with the development of JDBC, it can provide as senior functions such as connection pool, support distributed transactions.
Adopt the driver shown in table 4.1 and the table 4.2 respectively at the JDBC that in the application framework in water conservancy field, connects Sybase and oracle database: Driver com.sybase.jdbc2.jdbc.SybDriverClassnameURL jdbc:Sybase:Tds: machine domain name: port numbers/database name Library paths database installation directory/jConnect-
5_2/classes/jconn2.jar
Table 4.1 connects the JDBC driver Driver oracle.jdbc.driver.OracleDriverClassnameURL jdbc:oracle:thin:@ machine domain name of sybase database: port numbers: data
Storehouse SIDLibrary paths database installation directory
/ora90/jdbc/lib/classeslll.zip
Table 4.2 connects the JDBC driver of oracle database
Example is created table a: T_STN in database.CREATE?TABLE″T_STN″(″STNNO″VARCHAR2(10),″CTRNO″VARCHAR2(10),″STNNM″VARCHAR2(50),″FZR″VARCHAR2(20),″LXDH″VARCHAR2(50),″DZ″VARCHAR2(100),″YZBM″VARCHAR2(10))
2, make up the data set stratification
The data set stratification by with database table one to one local interface CMP entity B ean form.In the J2EE standard, the visit of data there is multiple mode: directly visit by JDBC by client layer; Utilize the JavaBean visit from the Web layer; Also can be through the operation layer visit.As the middle layer of sandwich construction core,, in the application system of reality, playing the part of vital role because it undertakes the pivotal role of " forming a connecting link ".The response that the middle layer is applied in assurance to transactional integrity, handle large-scale concurrent, to the interconnected transparent support of heterogeneous system, and the performance of the aspects such as security protection of application data will become the deciding factor of application system success or failure.Therefore, in the application and development of sandwich construction, the realization in middle layer is the key of whole application program.
Because the operation layer of J2EE standard is realized by the EJB member, and EJB can provide system-level services such as object persistency, security and transaction management automatically, thereby greatly simplifies performance history.Therefore the application framework towards the water conservancy field adopts the operation layer EJB member accessing database that passes through the J2EE standard.
Entity B ean is the member that is used to represent with the service data entity, is the reprint of data in Enterprise Java Bean container in the database.If a client stops using service or J2EE application server to be closed, Enterprise Java Bean container can be saved in the data of entity B ean in the database, so-called lasting data that Here it is.
Session Bean is mainly used to the service logic of the program of describing, and a session Bean represents application program and client's a conversation procedure.In program operation process, after the client executed operation, session Bean and its employed data can be deleted.
Because water conservancy field data class is various, both comprised that a large amount of spatial datas also related to a large amount of historical datas, can compare difficulty if therefore require programmer oneself to write database operating instruction, so in application framework, access of database is all adopted CMP entity B ean, by the responsible operation of container to database.The query language (QL) of EJB2.x makes searching with selection operation of CMP entity B ean become more flexible and easy simultaneously.
Session outward appearance (being called the session shop front again) Design Mode is that entity B ean layer is packaged in the session Bean layer that is called session outward appearance (the session shop front), and client can only access session Bean rather than entity B ean.Adopt the advantage of session appearance design pattern: prevent tight coupling between client and the business object; Prevent that the many remote method invocation (RMI) between client and the server from causing network performance problems; Can reduce the business object number of service layer on the network etc.
Because the water conservancy realm information comes the source distribution region wide, data transmission and processing real-time and security requirement height, so application framework has adopted the session skin mode that can alleviate network pressure and improve security at the EJB layer, entity B ean among the EJB and session Bean are used thoroughly separately.In application framework, access of database is all adopted and only adopts CMP entity B ean, with CMP entity B ean separately as one deck---the data set stratification, another advantage of doing like this is the data-switching of relevant database can be become object, provides than legacy data more function.
The session Bean of EJB2.x and entity B ean have the main interface of long-range and local two kinds.The key distinction of remote interface and local interface is: the caller of remote interface and the object that is called can be distributed in the network, and the caller of local interface and the object that is called must reside among the same JVM.
If the employing remote interface, even caller and be called object in same JVM still is a far call, the parameter of far call method and result realize the numerical value transmission.Each far call in the distributed system all needs huge expense: increase network traffics, need carry out safety inspection, need carry out transaction extension or the like, so operation is very slow.Test shows, the remote method invocation (RMI) among JVM is than slow 2000 times of local method call].And these measurements are carrying out on the abortive haul network fast, the general network communication stream remote method invocation (RMI) that then can further slow down.
The parameter of local call method and result realize quoting transmission, and data-switching can be carried out in server this locality, needn't consumption network etc. resource, and can be to remote client's hidden object model.
Consider of the specific (special) requirements of water conservancy message area application system to performance and safety, thereby the CMP entity B ean of data set stratification all adopts local interface to avoid the poor efficiency that remote interface brought in the application framework, reduces the performance cost of entity component to greatest extent.
Because the large database in water conservancy field maybe will have been realized standardization, large quantities of is that the list structure of the integrated data base of representative is determined already with real-time regimen storehouse, worker's feelings information database, social economy's information bank, shape library etc., or has entered into the data typing stage.Therefore the programming personnel is difficult to arbitrarily realize the view function according to the relation that user's request is set up between the data at database layer.
CMP2.x entity B ean with local interface can represent relation with abstract method, makes view can build the data set stratification in.But ean is when calling one of them for the CMP entity B that is mutually related, and will all activate all CMP entity B eans related with it, can influence system performance like this.And, in order to reach the purpose of software repeated usage, can not set up related at entity B ean layer.For this reason, the relation between the data just can only be placed on the realization of session Bean layer.
Consider component reusage need be in the local interface of CMP entity B ean some querying methods of definition as much as possible, set up a querying method as each field of correspondence database table at least.
Comprehensive above the analysis, data set stratification towards the integrated application framework of the informationalized middleware system of water conservancy adopts the CMP entity B ean with local interface, and a table in entity B ean correspondence database, like this on normalized basis, water conservancy field the data set stratification the same with data Layer can determine constant.
Example has table a: T_STN in the database.
Create CMP entity B ean:TStn in the data set stratification;
For being used for the session Bean that the data additions and deletions change, the upper strata provides service with following statement: public TStn create (String stnno, String ctrno, String stnnm, String fzr, String lxdh, String dz, String yzbm) throwsCreateException; The parameter and database table of //create method: the field of T_STN is corresponding one by one;
Provide service with following statement for the session Bean that the upper strata is used for data query: public Collection findByAll () throws FinderException;
With following EJB query statement underlying database table: T_STN is carried out query calls: SELECT OBJECT (ts) FROM TStn AS ts;
3, make up Business Logic
The Business Logic of application framework adopts the session Bean with remote interface.Owing to should adopt session appearance design pattern at the EJB layer with framework, the EJB layer is divided into entity B ean and session Bean is two-layer, be responsible for data integration with CMP entity B ean with local interface.Therefore the service logic of system just all is responsible for by session Bean.
Because water conservancy field application system complexity will be handled several data such as meteorology, water resource, water conservancy economy, make individual server possibly can't satisfy the demands; Because water conservancy information acquisition place covers seven big river basins, the whole nation,, need for this reason to consider that multiple servers provides service simultaneously simultaneously therefore possibly at the diverse geographic location deployment server.Therefore the application framework towards the water conservancy field is necessary weighing aspect distributivity and the system performance, handles huge application by the mode of cluster, not only can eliminate the weakness that there is Single Point of Faliure in centralized processing like this, also can reduce cost simultaneously.
Consider the needs of distribution, session Bean adopts remote interface, is deployed among the same JVM with CMP entity B ean in close relations with as the session Bean packing of packing.Owing to call entity B ean with local interface by session Bean, feasible repeatedly data value to database calls and becomes object reference one time, promptly provides high-level abstractions to the client, provides the coarse grain visit to the business object that participates in the system, reduce the consumption of Internet resources, improve system performance; And session Bean adopts remote interface, makes the EJB layer to operate on the different machines with other layer, improves system's distributivity.
Because the standardization of water conservancy field database structure makes and can't set up view according to user's specific demand at data Layer; The demand of considering component reusage and system performance can not adopt the related mode of abstract method foundation to set up view in the data set stratification.Therefore, can only set up view at Business Logic.
Concrete grammar: 1, if view comprises the field of several tables in the database, the mode of then taking to call a plurality of CMP entity B ean in the method for session Bean is set up view.2, if view comprises some field of a table in the database, then the parameter of session Bean method is set to corresponding one by one with required field.
Session Bean mainly is for the client carries out the data manipulation relevant with service logic, and whether according to client's session status is divided into two kinds of state and stateless are arranged in the support application program session.Here, so-called state is exactly the numerical value that uses in the operation.
Have state session Bean can put down in writing this Bean and a specific user's reciprocal process, because the additions and deletions of data are changed action need preservation information between method call, so all additions and deletions change operation and adopt state session Bean is arranged.
Stateless session Bean is quite simple, just once a client is provided service logic and do not preserve customer status between method call.The required system overhead of stateless session Bean is few, and retractility is good, therefore be used to inquire about and the session Bean of operation such as calculating adopt stateless so that set up more effective application program.
In sum, adopt the session Bean with remote interface towards the Business Logic of the integrated application framework of the informationalized middleware system of water conservancy, additions and deletions change operation to be adopted state session Bean is arranged, and stateless session Bean is adopted in other operation.
Example, data set stratification have a CMP entity B ean:TStn;
Business Logic create be used for that additions and deletions change operation state session Bean:zsg arranged
Call the service that the CMP of lower floor entity B ean:TStn provides: InitialContext initCtx=new InitialContext () with following statement; TStnHome home=(TStnHome) initCtx.lookup (" TStn "); TStn returnTStn=home.create (stnno, ctrno, stnnm, fzr, lxdh, dz, yzbm);
Provide service with following statement for the upper strata: public void addTStn (java.lang.String stnno, java.lang.Stringctrno, java.lang.String stnnm, java.lang.String fzr, java.lang.String lxdh, java.lang.String dz, java.lang.Stringyzbm) throws RemoteException;
Create the stateless session Bean:cx that is used to inquire about at Business Logic
Call the service that the CMP of lower floor entity B ean:TStn provides: InitialContext ctx=new InitialContext () with following statement; TStnHome home=(TStnHome) ctx.lookup (" TStn "); Collection result=home.findByAll ();
Provide service with following statement for the upper strata: public Collection getAll_TStn () throws RemoteException;
4, make up the interface control layer
The interface control layer of application framework adopts Servlet.Owing to have the burden that alleviates client computer, reduce soft, hardware configuration to client computer and require and reduce the advantages such as trouble of giving client software installation, so application framework is selected the service of calling the EJB layer by the Web layer for use based on the J2EE application program of Web.
Servlet (servlet) and JSP (Java Server Pages, java server dynamic web page technique) are the major techniques of J2EE Web layer.The Web layer is mainly used to handle HTTP (Hypertext Transfer Protocol, HTML (Hypertext Markup Language)) request, dynamically generates the response of HTTP according to the Servlet in the Web server and JSP.
Can't safeguard and the failure of total system because poorly designed Web interface will cause using, therefore be necessary to discuss the design of Web layer, to guarantee that the Web interface not only simply but also can safeguard.Cause the reason of water conservancy field Web layer exploitation difficulty to have:
1, the Web interface often changes: because the user of water conservancy system application program is extensive, the visual effect that different users uses Web requires different, but the variation of Web interface not necessarily changes workflow.Use in successful water conservancy field should be able to hold this variation, need not to revise simultaneously business object even Web layer control routine again.
2, the Web interface involves complicated page representation: the user interface in typical water conservancy field may comprise complicated page representation such as weather nephogram, electronic chart, rainfall isogram, and only substantial usually sub-fraction is dynamic.Therefore be necessary to distinguish page development personnel and Java developer's task, make the page development personnel be responsible for the design of static page specially, and be responsible for the control of dynamic content by Java developer.
3, have many efficient Considerations: usually, we can't limit or predict the number of users that uses a water conservancy field Web to use.For this reason, the performance of system and consistance may all be very important in water conservancy field Web uses.
In the J2EE standard, Servlet and two kinds of Web technology of JSP also there is multiple use-pattern.MVC (Model-View-Controller, model-view-controller) pattern is separated the expression (view) of data (model) with information, is that controller is used for control information flow between the two at this.According to each other mutual between this three is the basic engineering application program.
The MVC pattern makes every kind of element type that a clear and definite responsibility all be arranged: model does not contain the specific code of view; View does not contain control routine or data access code, the video data of only concentrating one's energy; Controller is created also more new model, and they do not rely on specific view and realize.
Because application framework has all been transferred to service logic session Bean and handled, therefore, the Web layer needn't be considered the problem of data model again.
Because complicacy that water conservancy field Web uses so application framework adopt the MVC pattern that the Web layer is separated into different two-layer of function fully: controller (interface control layer), view (customer interface layer).
Example has a session Bean:zsg at Business Logic
Create the Servlet:servlet_tstn_lr that is used for the data typing at the interface control layer;
Call down the service that layer conversation Bean:zsg provides with following statement: InitialContext ctx=new InitialContext (); Object objRef=ctx.lookup (" zsg "); The javax.rmi.PortableRemoteObject.narrow of zsgHome home=(zsgHome) (objRef, zsgHome.class); Zsg cust=home.create (); Cust.addTStn (stnno, ctrno, stnnm, fzr, lxdh, dz, yzbm);
With following statement control customer interface layer: RequestDispatcher rd=getServletContext () .getRequestDispatcher (goTo); GoTo=" customer interface URL ";
At Business Logic a session Bean:cx is arranged
Create the Servlet:servlet_tstn_cx that is used for data query at the interface control layer;
Call down the service that layer conversation Bean:cx provides with following statement: InitialContext ctx=new InitialContext (); Object objRef=ctx.lookup (" cx "); CxHome home=(cxHome) javax.rmi.PortableRemoteObject.narrow (objRef, cxHome.class); Cx cust=home.getAll_TStn ();
5, make up the customer interface layer
The customer interface layer of application framework adopts the JSP page.Because application framework adopts the MVC pattern the Web layer to be divided into: controller and view are two-layer, usefulness is not responsible for the Web interface control with the Servlet of display page function as controller.Therefore the customer interface layer of system just all is responsible for by view, like this, no matter uses which kind of view techniques, all needn't revise the code in the controller.
The advantage that controller and view separate fully: 1, it is the best approach that guarantees to separate Java developer and page development personnel role; 2, it guarantees to revise the expression at Web interface under the situation that does not influence the application program control flow; 3, it allows view synthetic.In view was synthetic, the output result or the content of pages of a plurality of views were combined, and did not influence the Java code simultaneously again.
Servlet and JSP can static and dynamically generate webpage in the J2EE standard.
Though Servlet provides the function of comprehensive dynamic generation web page contents, this technology has several weak points: because Servlet is pure Java code, so the developer must have enough Java program capabilities; It is cumbersome to generate HTML code with a lot of numerous and diverse println orders in Servlet, just must recompilate and dispose the Servlet program when only needing to change the expression at Web interface; In the debug process of Servlet program, very difficult What You See Is What You Get is seen page effect.
Compare with Servlet, JSP provides a kind of relatively generation webpage method of nature.It grows up on the Servlet technical foundation, adopts the text language based on webpage format, makes and also can write dynamic web page with the JSP label to the unversed developer of Java technology.Because and HTML is very approaching, the JSP technology is more suitable for writing the interface of Web program.
And the JSP page is not subjected to the restriction of client browser type, can also cross over fire wall, and therefore the application framework the superiors towards the water conservancy field adopt the JSP page.
Example has a Servlet:servlet_tstn_cx at the interface control layer;
Create the JSP page that is used for data query a: tstn_cx.jsp at the customer interface layer;
Be connected the generation dynamic web page with Servlet:servlet_tstn_cx with following statement:
<form?method=″post″action=″/servlet_tstn_cx″>
Theory and practice all proves, five layer architectures based on J2EE that are suitable for water conservancy system that adopt above step to make up, clear in structure, superior performance is easy to realize, is easy to multiplexing, have high security, reduce Internet resources and expend, further exploitation on this basis is very convenient.
Embodiment two
The present embodiment introduction is used for the five layer architecture construction steps based on J2EE of certain college library, university library, academic library's academic dissertation management system, and concrete condition is as follows:
1 systemic-function
Because academic dissertation occupies critical role in the self-produced document in libraries of the universities, and the computer management of academic dissertation effective method without comparison also at present.The multi-tier systematic structure of J2EE is applied to the book information field, realizes the online submission of academic dissertation, inquiry and classification automatically.
2 system development running environment
System hardware environment: database server: the Oracle9i database is installed; Application server: BEA WebLogic Server 6.1 is installed; System development microcomputer: the development platform of the Jbuilder7.0 of Borland company as system is installed.Below all adopt Pentium III microcomputer.
System software environment: operating system: Windows 2000 Server; Data base management system (DBMS): U.S. Oracle9i data base management system (DBMS); System development tool: Jbuilder7.0; System deployment instrument: WebLogic6.1.
3 system architectures
Five layer architectures that meet the J2EE standard have been realized: promptly, be divided into five layers with application program is bottom-up: data Layer, data set stratification, Business Logic, interface control layer and user interface layer.Each layer is specifically described as follows:
3.1 data Layer: the data Layer of native system adopts Oracle9i, and concrete library structure is as shown in table 3.
The table name remarks
The jb academic dissertation is submitted abridged table (paper front cover content) to
Fb academic dissertation subtabulation (front cover content in the paper)
Zy abstract (in the paper, english abstract)
Gjc antistop list (in the paper, English keyword)
Ckwx list of references (academic dissertation list of references table)
The flh sorted table (is provided the middle figure method and the UDC of paper automatically by system according to specialty
Classification number)
Dz reader's table (the record academic dissertation is borrowed information)
Tmb academic dissertation collection nomination table
Slfb water conservancy law sorted table (is provided the water conservancy of paper automatically by system according to keyword
The method classification number)
KL password table
Table 3: academic dissertation Management System Data library structure
XMLJNDIJDBC:<?xml version="1.0"encoding="UTF-8"?〉............<jndi-definitions〉<jndi-name〉serial://datasources/syq_xwlw</jndi-name〉............<datasource-class-name〉com.inprise.visitransact.jdbc1w2.InpriseConnectionPoolDataSource</datasource-class-name〉............<property〉<prop-name〉url</prop-name〉<prop-type〉String</prop-type〉<prop-value〉jdbc:odbc:syq_xwlw</prop-value〉</property〉//odbc<property〉<prop-name〉driverClassName</prop-name〉<prop-type〉String</prop-type〉<prop-value〉sun.jdbc.odbc.JdbcOdbcDriver</prop-value〉</property〉//JDBC-ODBC</driver-datasource〉</jndi-definitions〉
3.2 data set stratification: the data set stratification of native system adopts the CMP2.0 entity B ean with local interface to realize.In order to realize component reusage, each table in the corresponding academic dissertation database is built a CMP2.0 entity B ean.
Example, entity B ean:Jb XML file description following (ean is similar with it for other entity B):
<display-name〉Jb</display-name〉// JNDI when entity B ean:Jb disposes;<ejb-name〉Jb</ejb-name〉// name of the relevant entity B ean:Jb of abridged table jb submitted to academic dissertation;<local-home〉syq_xwlw.JbHome</local-home〉// the local main interface of entity B ean:Jb;<local〉syq_xwlw.Jb</local〉// the local component interface of entity B ean:Jb;<ejb-class〉syq_xwlw.JbBean</ejb-class〉// the realization class of entity B ean:Jb;<persistence-type〉Container</persistence-type〉// persistence of entity B ean:Jb is by Container Management;<cmp-version〉2.0</cmp-version〉// entity B ean:Jb follows the EJB2.0 standard;
In the local interface JbHome of Jb, following statement is arranged, for last layer conversation Bean provides service: public Jb findByPrimaryKey (String xh) throws FinderException;
Use following statement, underlying database table: jb is carried out query calls; SELECT OBJECT (j) FROM Jb AS j WHERE j.xh=? 1;
3.3 Business Logic: the used EJB member of academic dissertation management system adopts session shop front Design Mode.Bean provides high-level abstractions to the client with session, provides the coarse grain visit to the business object that participates in the system; With entity B ean abstract data source, and provide the transparent access of data.So the native system Servlet of session Bean linkage interface key-course and the entity B ean of data set stratification.
Session Bean connects with lower course of solid Bean with following statement: // submit to the relevant entity B ean:JbHome of abridged table to get in touch sessionContext=new InitialContext () with academic dissertation; JbHome home=(JbHome) sessionContext.lookup (" Jb "); ReturnJb=home.findByPrimaryKey (xh); The keyword of //Jb is: xh
Four session Bean (dl, cx, tj, fl) that native system adopts all adopt remote interface, make to dispose with the application server of issue EJB and can reside on the different physical servers with the Web server of disposing with issue JSP and Servlet.
3.4 interface control layer: native system uses Servlet as the connection between JSP and the session Bean.In Servlet, be connected with upper strata JSP: public void doGet (HttpServletRequestreq with following statement, HttpServletResponseres) throws IOException, ServletException{RequestDispatcher rd=getServletContext () .getRequestDispatcher ("/dl.jsp "); Rd.forward (req, res); }
With following statement and with the session Bean:dl of the lower floor user rs authentication InitialContext ctx=new InitialContext () that interrelates; Object objRef=ctx.lookup (" dl "); DlHome dHome=(dlHome) javax.rmi.PortableRemoteObject.narrow (objRef, dlHome.class); Dl d=dHome.create ();
3.5 customer interface layer
The user interface of system all adopts the JSP page, and JSP only is responsible for handling the interface and represents.The advantage of Chu Liing is like this: development can be divided the work, design static page by special art designing personnel.In JSP, use following statement to be connected:<form method=" post " action="/servlet_dl "〉with the Servlet of lower floor
The function of worker's feelings database inquiry system and certain academic dissertation management system user of college library, university library, academic library login is re-used in real time, has promptly realized the page: the dl.jsp from JSP; Table in the CMP entity B ean:Kl → database of dl_err.jsp → Servlet:servlet_dl → stateless session Bean:dl → have local interface: the allomeric function module of KL is the component reusage of unit.
In addition to the implementation, the present invention can also have other embodiments.All employings are equal to the technical scheme of replacement or equivalent transformation formation, all drop on the protection domain of requirement of the present invention.

Claims (8)

1. five layer architecture construction methods based on J2EE may further comprise the steps: on computer operating system
1), makes up data Layer---opening relationships type database, in order to the storage service data, for adjacent upper strata provides service;
2), make up the data set stratification---adopt Container Management persistence entity B ean to set up the data set stratification of constructing on data Layer with local interface, a unit of the corresponding described database of each described entity B ean, in order to will sending database to session Bean data processed, and send the data in the database to session Bean by entity B ean;
3), make up Business Logic---adopt session Bean to set up the Business Logic of constructing on the data set stratification with remote interface, be deployed in the same Java Virtual Machine with closely-related Container Management persistence entity B ean with as the session Bean packing of packing, in order to will sending entity B ean to the Servlet data processed, and will send Servlet to entity B ean data processed by session Bean;
4), make up the interface control layer---adopt Servlet to set up the interface control layer of constructing on Business Logic, ask in order to dynamic process network HTTP, generate http response, processing controls stream and startup business operation, send user's data processed in the java server page to session Bean by Servlet, and will send the java server page to session Bean data processed;
5), make up the customer interface layer---adopt the java server page to set up the customer interface layer of constructing on the interface control layer, in order to sending user's operation to Servlet, and will send the user to the Servlet data processed by the java server page.
2. according to the described five layer architecture construction methods based on J2EE of claim 1, it is characterized in that: MVC---model-view-director mode is separated into different interface control layer of function and customer interface layer fully with the Web layer in employing.
3. according to the described five layer architecture construction methods based on J2EE of claim 1, it is characterized in that: described data set stratification realizes safety, transactional integrity, telecommunication and retractility service automatically by Enterprise Java Bean container.
4. according to the described five layer architecture construction methods based on J2EE of claim 1, it is characterized in that: described data set stratification is by having the entity B ean visit data layer of local interface.
5. according to the described five layer architecture construction methods based on J2EE of claim 1, it is characterized in that: the additions and deletions of described Business Logic change the operation employing state session Bean; Be used for inquiry and calculating operation and adopt stateless session Bean.
6. according to the described five layer architecture construction methods of claim 5 based on J2EE, it is characterized in that: described Business Logic is set up view according to the following steps, if view comprises the field of showing more than two in the database, then take in the method for session Bean, to call two above CMP---the mode of the persistence entity B ean of Container Management is set up view; If view comprises the field of a table in the database, then the parameter of session Bean is set to corresponding one by one with required field.
7. according to the described five layer architecture construction methods based on J2EE of claim 5, it is characterized in that: described Business Logic provides high-level abstractions with session Bean, provides the coarse grain visit to the business object that participates in the system; With entity B ean abstract data source, and provide the transparent access of data.
8. according to the described five layer architecture construction methods of claim 7 based on J2EE, it is characterized in that: described session Bean all adopts remote interface, disposes with the application server of issue EJB to reside on the different physical servers with the Web server of disposing with issue JSP and Servlet.
CN 200410014139 2004-02-23 2004-02-23 Structure method of five-hierarchical system structure base on J2EE Expired - Fee Related CN1259623C (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN 200410014139 CN1259623C (en) 2004-02-23 2004-02-23 Structure method of five-hierarchical system structure base on J2EE

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN 200410014139 CN1259623C (en) 2004-02-23 2004-02-23 Structure method of five-hierarchical system structure base on J2EE

Publications (2)

Publication Number Publication Date
CN1560741A CN1560741A (en) 2005-01-05
CN1259623C true CN1259623C (en) 2006-06-14

Family

ID=34440216

Family Applications (1)

Application Number Title Priority Date Filing Date
CN 200410014139 Expired - Fee Related CN1259623C (en) 2004-02-23 2004-02-23 Structure method of five-hierarchical system structure base on J2EE

Country Status (1)

Country Link
CN (1) CN1259623C (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106875150A (en) * 2015-12-14 2017-06-20 重庆森坦科技有限公司 A kind of product transaction tracking system

Families Citing this family (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN100409184C (en) * 2005-10-20 2008-08-06 北京航空航天大学 Pattern-oriented engine-drawing IO intermediate device
CN100456721C (en) * 2006-08-03 2009-01-28 上海宝钢钢材贸易有限公司 Intraconnection network structure and method for establishing intraconnection network
CN100428166C (en) * 2006-12-31 2008-10-22 华为技术有限公司 Processing method for use in client terminal having an access to EJB through remote interface and device therefor
CN102195829B (en) * 2010-03-19 2014-05-14 升东网络科技发展(上海)有限公司 Universal pressure simulation system and control method thereof
CN102148869B (en) * 2011-02-12 2013-05-01 惠州Tcl移动通信有限公司 Method and device for JAVA application to transfer information to local
CN103123593B (en) * 2011-11-18 2016-08-31 腾讯科技(深圳)有限公司 Java application server and the method processing Web service
CN103473483A (en) * 2013-10-07 2013-12-25 谢华林 Online predicting method for structure and function of protein
CN104462545B (en) * 2014-12-24 2017-12-19 国家电网公司 A kind of page building method and device based on three layer model
CN106569794B (en) * 2016-09-23 2020-03-24 北京五八信息技术有限公司 Application program development device
CN108279880A (en) * 2018-01-26 2018-07-13 长春玖佰软件技术有限公司 A kind of configuration method of enterprise's application framework
CN108829377A (en) * 2018-05-10 2018-11-16 芜湖航飞科技股份有限公司 A kind of detection based on radar and communication for coordination integrated system
CN110069356A (en) * 2019-04-25 2019-07-30 北京东方通科技股份有限公司 A kind of application server

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106875150A (en) * 2015-12-14 2017-06-20 重庆森坦科技有限公司 A kind of product transaction tracking system

Also Published As

Publication number Publication date
CN1560741A (en) 2005-01-05

Similar Documents

Publication Publication Date Title
CN1259623C (en) Structure method of five-hierarchical system structure base on J2EE
CN1223938C (en) Method of packing member and consistent visit
US7340714B2 (en) System and method for using web services with an enterprise system
CN100337235C (en) Method and apparatus for accessing database
CN102375731B (en) Coding-free integrated application platform system
CN1554046A (en) System and method for transaction processing with transaction property feature
CN1662899A (en) Network service agent
CN1875344A (en) Introductory operation support system for integrated business software
CN101046810A (en) System for automatic setting relation model and its method
CN100351828C (en) File access method based on a distributed file storage system
CN1577322A (en) Method and system for application installation and management using an application-based naming system including aliases
CN101040280A (en) Metadata management
CN1764183A (en) QoS driven computer system for providing combined Web service based on computer network
CN101206568B (en) Gridding application program interface system based on Web
CN1913442A (en) Method and system for providing service to user
CN1805345A (en) Web service work flow processor
CN1662011A (en) System and method for building component applications using metadata defined mapping between message and data domains
CN108108460A (en) A kind of standardized work flows intelligent management system framework and system
CN1842078A (en) Gridding service container
CN1228728C (en) System and process for developing customized business report forms in the WEB applications
CN1255744C (en) Universal high speed IC card issuing apparatus and method
CN1540481A (en) Method for using synergic multiple computer engines based on gridding environment
CN1956445A (en) Implementing method faced to gate package of web service
CN101321178A (en) Portal workflow engine system and its implementing method
CN1885266A (en) System, device, and method for cooperative processing

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
C14 Grant of patent or utility model
GR01 Patent grant
C17 Cessation of patent right
CF01 Termination of patent right due to non-payment of annual fee

Granted publication date: 20060614

Termination date: 20140223