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

Source: Internet
Author: User
Tags log requires version 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 framework based on business needs





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 Java EE applications 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, in the JBoss 3.2.1 for entity Beans Cache strategy, you can consider the use of, that is, "Standard CMP 2.x Entitybean", the Way and "D" Type of 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 to 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, such as TopLink, that can be used here.





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, and the local interfaces, CMR, Read-only, and session Fa?ade modes have injected vitality 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 the realization of their own specific design patterns, or through the Third-party Framework. If your company is not big, or that the company does not want to invest a lot of energy in the Java EE Foundation Application Framework, it would be wise to choose the more mature, stable, and compatible technical framework with existing Java EE specification.





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. For example:


Struts: For the framework of Model 2, it would be wise to choose her now and in the future (as the JSF specification and 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 the next generation Java platform technology JSF with the. NET Web forms feature, struts itself takes 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 want to use "System.out.println (") for the habit. " Readers, log4j is the gospel of everyone. 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.





under normal circumstances, the target product to be developed should not adopt too much framework. First, the technology development of Java EE is very fast, too much framework makes the follow-up upgrade, maintenance disadvantage; Second, we can learn from the good side, such as the study of the corresponding design model realmethods, and to adapt her to meet our project needs; The framework itself will be changed, if the choice of too much, will add to the development team burden, which is not conducive to project management. Selective use of existing mature framework can improve the development efficiency, development level.





3, the choice of development mode





development of Java EE application requires the target developer to master the various technologies. However, the reality is not the case. As a team, each person has his or her own different skills, interests, and savvy. At the same time, the Java EE itself needs to embody social division. In general, our development team will not have the various development roles required by specification. There are usually only 3 kinds of reality (and possibly two): art, JSP programmers, EJB programmers. In the face of this division of labor, the team should pay attention to communication, communication, pay attention to the consistency of the code.





In general, the team should try to use the version Control tool to manage the code and try to have a complete running version every day. Over time, the team adapts to this development pattern. The version control tools must be used to facilitate the management, control, and backup of the code. There are many levels involved. For example, the choice of development tools should take into account the use of version control tools, the rational use of modeling tools to facilitate effective team communication and communication.





based on the existing development model, individuals think that 3 sets of programs are good. First, using together as a modeling tool, using JBuilder as an IDE tool, using VSS (or CVS) as a version control tool, and using JBoss as a server to develop the Java EE application development phase. Second, use the WebSphere Studio suite of tools. Third, use Eclipse (or JCreator), Ant, xdoclets as a development tool.





of course, writing, compiling, packaging, deploying, and testing the Java EE application manually can make developers understand the specifics of each development phase. But I think, as long as developers have this attention to specific details of the attitude, the use of powerful modeling, development tools is sensible. Development tools do not improve developer skills, but she can guide developers in the right direction of development. For example, the Jbuidler 9 Enterprise provides the EJB Wizard with "Struts + EJB + Session Fa?ade + Value Object" features such as the industry's widely used Java-EE architecture.





4, pay attention to the test work of each stage





test work is often overlooked by many project managers, unwilling to spend time and expense content, because that would increase the cost of the project. However, they ignore that the quality of project completion often has a great relationship to the cost of the project. For example, if the software quality is poor, and did not experience the testing phase, its late deployment, operation costs will be far more than upfront costs.





The test is staged. Unit tests, such as the use of junit, to ensure that functionality is correct. Integration testing to ensure that the system does not have memory leaks and other content. Among them, the Optimizeite Suite Enterprise is helpful for completing Profiler, Code Coverage, Thread debugger, and so on. I remember that I wrote a swing desktop application with content leaks, but there are many ways to solve the problem. Later, the answer was obtained using profiler. As a result, we use the Optimizeite Suite Enterprise as a test tool for many times now to develop applications. In particular, during the integration testing process, it is helpful to check the memory leak and performance of the system.




The
test is of a separate type. Stress testing, performance testing. There is no good testing tool for current tests that support Java EE applications. However, in general, the use of rational robot can also achieve good results.





of course, there are many factors for successful development of Java EE application. For example, the successful application of Entity beans is largely related to the design of the underlying database (if the design of the table structure is unreasonable, it will lead to a sharp decline in Entity beans performance) and how to maximize the ability to excavate and enhance the Java EE skills of each member of the team. And so on, the design is very wide.








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.