[Getting started with Java] how to master Java (J2EE)

Source: Internet
Author: User

J2EE is a complete set of standardized integration platforms for developing enterprise applications of mission-critical. Its many specifications and wide content bring a lot of "trouble" to the Development of J2EE applications ". For example, to implement Content-based RDBMS storage, we may use JDBC, Entity Beans, JDO, O/R Mapping tools (TopLink, Hibernate), XML-DBMS, JAXB, and other methods (some of which are not included in the J2EE specification ). Therefore, to realize the coupling between layers (at least three layers of J2EE, including the presentation layer, control layer, and commercial logic layer) and between layers, the J2EE system architect has many issues to consider. In addition, the rapid development of J2EE brings some difficulties to the architecture and development of industrial-strength J2EE applications.
At the same time, software development technology has never been "Silver Bullet", so J2EE technology is not omnipotent. However, if we properly apply the J2EE technology based on specific business needs, the results can be imagined. This article tries to explore some of the tests that J2EE applications should follow from their previous project experience, so as to serve as a reference. If you can meet this requirement, you will be very excited.
This article takes J2EE application development under JBoss 3.2.1 as an example to describe.

1. Select a reasonable architecture based on business needs
 
It is not enough to discuss the advantages of technology independently from business needs. Various technologies have specific backgrounds, many of which are driven by industrial needs. Generally, enterprise information systems (EIS) require stability, security, reliability, efficiency, and easy maintenance. At the same time, each enterprise's information system has its own unique requirements, and sometimes it is necessary to consider integration with the original legacy system, therefore, understanding the specific business needs of enterprise information systems is critical to the entire system architecture.
For example, if most of the data used in the J2EE application system to be developed comes from external data sources; the data may be imported directly from the external data source to the Database of the J2EE system to be developed through JDBC. In this case, if you only use JDBC to operate the database during the development process, it is obviously appropriate for scenarios with low strength (fewer concurrent users and less data streams; however, if the Database layer is frequently used due to a large number of concurrent access users and a large amount of data streams, it seems a little powerless. Therefore, for this requirement, we can consider using Entity Beans with Caches. For example, there are multiple Cache policies for Entity Beans in JBoss 3.2.1. You can consider using these policies, that is, "Standard CMP 2.x EntityBean ", the "D" type commit-option method is used to ensure the synchronization of Entity Beans content and data sources, and greatly improve the system performance (compared with the direct use of JDBC ). You can set some Entity Beans to read-only to improve performance.
Of course, other O/R Mapping technologies, such as TopLink, can also be used here.
For another example, consider the following situation: if the data used by the enterprise information system to be developed is generated and operated by the system itself, we recommend that you use the CMP Entity Beans technology. Entity Beans has a bad impression on everyone. This may be related to the bad image that EJB 1.1 has left for everyone. However, EJB 2.0 (or 2.1) has been greatly improved, including Local Interfaces, CMR, Read-Only, and Session Fa? The ade mode Injects Vitality into Entity Beans. Of course, the advantages of Entity Beans can be reflected only when many concurrent users and large data traffic are involved. One of the key points is to pay attention to the performance tuning of Entity Beans technology. Each application server has its own performance tuning solution. For JBoss 3.2.1, the configuration file standardjboss. xml provides an entry for Entity Beans technical optimization. For example, the rational use of Bean Lock policies is very important for tuning Entity Beans. In this way, we can focus more on the commercial logic of the system, not just the underlying Database (EJB tuning is in the EJB iner, so we are at the high-end of J2EE performance, not the bottom, that is, the Database layer. At the same time, the Database-layer optimization greatly compromises the Database portability of the J2EE system .).
In short, we need to give specific technical architecture solutions based on the specific needs and conditions of each system, rather than discussing the quality of the technology itself alone.

2. Reasonable Selection of Framework

The design pattern plays an important role in the J2EE application system. Therefore, there is a question for everyone: whether to implement a specific design pattern or use Third-party Framework. If your company is not large, or you do not want to invest a lot of energy in the basic J2EE application Framework, it would be wise to choose a more mature and stable technical Framework that is compatible with the existing J2EE Specification.
Generally, the Framework itself, or the J2EE platform itself, implements and optimizes specific design patterns and rules, such as Service proxies and Service Locator (including the Service Locators of Web Tier and EJB Tier respectively, provides centralized management of limited resources and Cache-related resources to facilitate system migration), Front Controller, DAO, and so on. The existing J2EE Framework is rich. For example:
Struts: it is wise to use the Framework of Model 2 in the present and future (along with the maturity of JSF specifications and technologies. Currently, Struts has been developed to version 1.1. Its internal MVC main line, no restrictions on backend data operations, and the excellent related projects of the Apache Jakarta project team are the best products for developing J2EE applications. At the same time, for the next-generation J2EE platform technology JSF with. NET Web Forms features, Struts itself can take into account the compatibility and integration with JSF. For example, the presentation layer is presented through JSP, the Servlet presentation control layer, and the EJB presentation data storage layer. Each layer can communicate with each other through value objects and HTTP-related objects to achieve perfect application of J2EE-related technologies.
Log4j: I think Log4j is a boon to readers who are used to "System. out. println. Although Java 2 Standard Edition has a java. util. logging package to ensure log output, the simplicity, efficiency, and flexibility of Log4j have become the choice of many projects. To some extent, logs can test the stability and correctness of the system. Therefore, you can use configurable Log4j (currently, Log4j has been taken into account with java. util. logging package compatibility. For example, JBoss 3.2.1 uses Log4j to manage logs.
RealMethods: Some readers may not know this killer yet. Well, here is a brief introduction. RealMethods is a Framework for developing J2EE applications. It is different from Struts (mainly in Model 2 and J2EE application front-end). realMethods provides detailed and efficient support for all aspects of J2EE applications. At the same time, realMethods was previously a commercial software and has now become an Open Source product. Therefore, you can refer to all its Source code.
BC4J: A commercial component launched by Oracle for Java. Its content and external features and advantages are not reserved.
Of course, there are many similar frameworks. As a team developing J2EE applications, we need to filter various frameworks and select a Framework suitable for the project requirements, teams, and company development directions.
Generally, too many frameworks are not suitable for the target products to be developed. First, various J2EE technologies have developed rapidly, and too many frameworks make subsequent upgrades and maintenance of the system unfavorable. Second, we can learn from the good aspects, such as studying the corresponding design modes implemented by realMethods, and transform her to suit our project needs. Third, the Framework itself will change. If too many options are selected, it will increase the burden on the development team, which is not conducive to project management.
You can use the existing mature Framework to improve your development efficiency and level.

3. Development Mode Selection

Developing J2EE applications requires target developers to master various technologies. However, this is not the case. As a team, everyone has their own different skill advantages, interests, and insights. At the same time, J2EE itself needs to reflect the social division of labor. Generally, our development team does not have the various development roles required by Specification. There are usually three types of reality (or two types): artist, JSP programmer, and EJB programmer. In the face of such division of labor, the team should pay more attention to communication, communication, and code consistency.
In general, the team should try to use version control tools to manage code and try to have a complete running version every day. After a while, the team will adapt to this development model. Version control tools must be used to facilitate code management, control, and backup. This involves many layers. For example, the selection of development tools should take into account the use of version control tools and the rational use of modeling tools to facilitate effective communication and communication between teams.
Based on the existing development model, I personally think these three solutions are good. First, use Together as the modeling tool, use JBuilder as the IDE tool, use VSS (or CVS) as the version control tool, and use JBoss as the server for developing J2EE applications. Second, use the full set of WebSphere Studio Tools. Third, use Eclipse (or JCreator), Ant, and XDoclets as development tools.
Of course, manual compilation, compilation, packaging, deployment, and testing of J2EE applications allow developers to understand the details of each development stage. However, I believe that it is wise for developers to choose powerful modeling and development tools as long as they are concerned about specific details. Development tools cannot improve the development skills of developers, but they can guide developers in the correct development direction. For example, the EJB genie provided by JBuidler 9 Enterprise has "Struts + EJB + Session Fa? Ade + Value Object "and other functions present the J2EE architecture that is widely used in the industry.

4. Focus on testing at various stages

Testing is often overlooked by many project managers, who are unwilling to spend time and money, because it will increase the cost of the project. However, they ignore that the quality of project completion often has a great relationship with the cost of the project. For example, if the software quality is poor and has not gone through the test phase, the cost of subsequent deployment and operation will far exceed the cost of the early stage.
Testing is performed in stages. Unit tests, such as JUnit, are used to ensure proper functions. Integration testing to ensure that the system has no memory leakage and other content. Among them, Optimizeite Suite Enterprise is very helpful for completing Profiler, Code Coverage, Thread Debugger and other content. I remember that the content of a Swing desktop application I wrote was leaked, but I did not solve the problem in many ways. Later, the answer was obtained using Profiler. Therefore, currently we use Optimizeite Suite Enterprise as a testing tool to develop applications. In particular, it is helpful to check the system memory leakage and performance during integration testing.
Tests are classified. Stress testing and performance testing. Currently, there is no good testing tool for tests that support J2EE applications. However, generally, with the help of Rational Robot

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.