Some principles to be followed in developing the application of Java EE

Source: Internet
Author: User
Tags jboss log4j

Java EE, as the development of mission-critical enterprise-class application of a set of standardized integration platform, more specifications, a wide range of content, so as to develop Java application has brought a lot of "trouble." For example, to implement RDBMS storage for content, we might have JDBC, Entity Beans, JDO, O/R mapping Tools (TopLink, Hibernate), Xml-dbms, Methods such as JAXB (some of these methods are not included in the Java EE specification). Therefore, to achieve the Java EE layer (at least the presentation layer, control layer, business logic layer, etc., 3 layers) and the coupling between layer and layer, Java EE System Architects need to consider a lot of problems. Plus, the rapid development of Java-EE itself, to the structure, the development of industrial strength of the application of Java EE brought some difficulties.

At the same time, software development technology has never "silver bullet", so the technology is not omnipotent Java. However, if we combine the specific business needs on the basis of reasonable application of good Java technology, the results are conceivable. This paper attempts to start with my previous project experience, to explore the development of the application of Java EE should be followed by several criteria, hoping to play a role in the discussion. In this paper, we discuss the application development of Java EE under the 3.2.1 of JBoss.

1. Choose a reasonable structure based on business needs

It is not enough to separate the advantages of the technology itself if it is divorced from business needs. Various technologies have a specific background, many of which are triggered by industrial demand. Generally speaking, enterprise Information System (EIS) requires itself to be stable, safe, reliable, efficient and easy to maintain. At the same time, each enterprise information system has its own unique requirements, may sometimes need to consider the integration of legacy systems, so understanding the specific business needs of various enterprise information systems is critical to the overall system architecture.

For example, if most of the data used in the Java EE application to be developed comes from external data sources, the data may be imported directly from the external data source to the database of the Java EE system to be developed via JDBC. In this case, if in the development process, only use JDBC to operate the database, for small intensity (concurrent access to the user, less data traffic) situation, obviously is more appropriate, but if, concurrent access to more users, large data flow, to the database layer more frequent use of the situation, It seems to be a little powerless. Therefore, for this kind of demand, we can consider using entity Beans with caches. For example, there are several cache strategies for entity Beans in JBoss 3.2.1, which can be considered, that is, "Standard CMP 2.x Entitybean ", using the" D "type commit-option to ensure that the content of the entity beans is synchronized with the data source, and that the performance of the system is greatly improved (compared with the direct use of JDBC). Some of the entity beans can be set to read-only to improve performance. Of course, there are other R/O mapping technologies available here, such as TopLink.

Consider, for example, the fact that if the data used by the enterprise information system to be developed is generated and manipulated by the system itself, it is recommended that CMP Entity beans technology be used. Entity beans to everyone's bad impression, which may be related to the bad image that EJB 1.1 left us. However, EJB 2.0 (or 2.1) has been greatly improved, local interfaces, CMR, read-only, session Fa? The ADE model injected vigor into entity beans. Of course, many concurrent users, data flow is very large will reflect the use of entity beans advantage. One of the key points: to pay attention to the performance tuning of entity beans technology, each application server has its own set of performance tuning program. For JBoss 3.2.1, the configuration file Standardjboss.xml provides a entity Beans technology tuning Portal. For example, the proper use of the Bean lock strategy is important for entity beans tuning. This allows us to focus more on the business logic of the system, not just the underlying database (EJB tuning is in EJB container, so we are at the high-end of Java EE performance, not the bottom, the database layer. At the same time, the database layer of the optimization of the Java-EE system has greatly reduced the portability of databases. )。

In short, to combine the specific needs and conditions of each system to give specific technical framework solutions, and not alone to discuss the quality of the technology itself.

Reasonable selection of 2.Framework

The design pattern plays an important role in the Java EE application System. Therefore, there is a problem in front of everyone, is to realize the specific design pattern, or the use of the Third-party Framework. If your company is not big, or the company does not want to be in the Java EE Foundation Application Framework to invest a lot of energy, choose the existing more mature, stable, The technology framework compatible with existing Java EE specification will be wiser.

In general, the framework itself, or the Java-EE platform itself, implements and optimizes specific design patterns, rules, such as business proxies, service Locator (including Web tier and EJB tier, their respective services locators, and unified management of limited resources, Cache related resources, easy to transplant system, Front Controller, DAO and so on. The existing Java-EE framework is quite rich. Like what:

Struts: For the framework of Model 2, it would be wise to choose her now and in the future (as the JSF specification, technology matures). Currently, struts has developed to version 1.1. Its intrinsic MVC main line, to the back-end data operation method has not limited, assembled the Apache Jakarta Project group outstanding Related Project's essence, is the development Java EE application Jiapin. At the same time, for having. NET Web Forms features next-generation Java platform Technology JSF, struts itself can take into account compatibility and integration with JSF. For example, the JSP renders the presentation layer, the Servlet rendering control layer, and the EJB rendering data storage layer. Between each layer, we can communicate with the value object and HTTP related object to realize the perfect application of Java-related technology.

LOG4J: I think log4j is the gospel for the reader of the habit of "System.out.println". Although the Java 2 Standard Edition also has a java.util.logging package to ensure log output, log4j's simplicity, efficiency, and flexibility have become a choice for many projects. Log, to some extent, can test the stability of the system, correctness, so the use of configurable log4j (currently, LOG4J has taken into account the compatibility with the Java.util.logging package) is not wrong. For example, JBoss 3.2.1 itself is the use of log4j to manage the log.

Realmethods: Some readers may not yet know the killer. Well, here's a brief introduction. Realmethods is a development of Java application Framework, she is different from struts (mainly in the implementation of Model 2,J2EE application front-end), realmethods for all aspects of the application of Java EE have detailed and efficient support. At the same time, Realmethods used to be commercial software and now has become a product of open source, so you can now see all of its source code.

Bc4j:oracle's business component for Java. Its content and external characteristics and advantages, it goes without saying.

Of course, there are a lot of similar frameworks. As a team that develops Java EE applications, we need to sift through the various frameworks and choose the framework that fits the needs of the project, the team, and the direction of the company's development.

In general, the target product to be developed should not adopt too many frameworks. First, the various technology of Java EE Development quickly, too much of the framework of the system to upgrade and maintain adverse; second, we can learn from the good side, For example, to study the corresponding design pattern of realmethods implementation, and to adapt her to meet our project needs, the framework itself will be changed, if too many, it will burden the development team, which is not conducive to project management. Selective use of existing mature framework can improve the development efficiency, development level.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.