Compared to the Tomcat,glassfish user base is not so broad, but because it is also free, open source, and has such as delayed loading, grizzly and other technologies, is gaining recognition. JSF, a standard for web development, has been controversial since its inception, but it is also winning more developers ' eyes in the controversy. Anissa, one of GlassFish's major authors, led its management console project and worked for the Sun's application server team for 7 years. Hotte, editor of the Infoq Chinese station, was fortunate to have interviewed Anissa about JSF's application in the GlassFish management console, such as why JSF templates were applied in the GlassFish management console, how JSF was unit tested, the JSF component library, and how to improve JSF performance.
Infoq Chinese Station: Please introduce yourself and the technical field currently being studied.
Anissa: I am the main submitter of GlassFish, currently leading its management console project. About seven years ago, I joined the application Server team, when GlassFish was not open source. I have been involved in many GUI tools, including the Deploytool in the Java EE 1.4 Reference implementation and our popular Ide_netbeans plug-ins, and are now responsible for managing the console. During these years, I have witnessed the development of Web application development technology and benefited a lot from it. I'm currently focused on Web 2.0, dedicated to applying the latest technology to the GlassFish management console.
Infoq Chinese Station: GlassFish's management console uses the JSF template, please introduce the reasons for choosing this technology.
ANISSA:JSF is a component-oriented framework. As a result, it is easy to organize a variety of "components" with complex capabilities into a Web page that includes file selection, file uploads, tables, BreadCrumb, property sheets, and many other components. However, JSF 1.2 does not provide a concise way to reuse GUI display logic or to organize pages through templates. Jsftemplating makes defining pages more efficient by coordinating templates. It also adds a number of features and other useful features designed to encourage code reuse. These features include a fine-grained event model, a reusable "processing function" that can be parameterized, support annotations, page scopes, the ability to convert any content source into a resource flow, and a customizable component factory. These features, combined with JSF's rich component model, provide a rich development environment for creating the GlassFish management Console.
Infoq Chinese Station: One of the original aims of JSF is rapid development, but unit testing is just as important as rapid development. How do you do JSF unit tests?
Anissa: I have to admit that the unit testing of the management console is one of the most flawed areas and needs to be improved. For GlassFish V2, we have studied and used selenium to do some testing, although selenium is more suitable for functional testing. We also rely on quality assurance departments to automate the testing of the console. For GlassFish V3, we're working on different frameworks, such as Jsfunit, which can be part of the MAVEN build process and Hudson.
Infoq Chinese Station: The current error tip on JSF seems less intuitive, too low-level, what are your skills for locating errors?
The ANISSA:JSF error message continues to improve from 1.0 onwards. Unfortunately, many times people face misinformation and still need enough knowledge of how JSF works to fully understand it. It often takes experience to identify the source of the error. However, here are some tips to help you:
View the JSF source code. JSF is open source, do not be afraid to get the source code, look at where the error occurred at the code.
Bad error messages are reported. When you don't understand the meaning of the error message, go to https://javaserverfaces.dev.java.net and submit a "question" that will help improve the error message and you'll probably get the answer to the question you're having.
Use Google to ask questions on the forum. There are a lot of people using JSF, and maybe someone has already met and raised this question. If not, you will find that many people are willing to help you and answer your questions.
Verify that you are using the JSF "h:messages" component (or another component that displays the content). JSF often reports errors using the "faces message" mechanism, and you cannot see them if you do not include the "h:messages" component on the page.
Using these techniques, you can solve any problems you encounter.
Infoq Chinese Station: JSF used to do heavy business, light page of the enterprise development is also more appropriate, but now customers also pay more attention to the page, the interface design also put forward a high demand. The visual editing Web interface can be achieved through IDE,JSF, but how can developers and web developers collaborate efficiently? How did you work with art when you were developing JSF?
Anissa: Our products have a very clear standard for the concept of interface design. The components we use (Woodstock) reflect this design requirement by default. As a result, JSF's component-oriented nature provides us with a lot of look-and-feel choices, without the need for too much development work. That is, there are some parts of our product that need to customize the picture, decide how to display the information, and there are some places that are not covered by the JSF Woodstock component. In this case, we work with art to create pictures, or they help us decide which components are most appropriate, or set standards for new components. If new components are needed, we often have the Woodstock team in charge of this work-and we do it ourselves when we can't wait. Art usually provides pictures and HTML, which we convert into JSF pages or components.
Infoq Chinese Station: How does the management console use AJAX technology?
Anissa: In GlassFish V2, we use AJAX to compute breadcrumb on most pages. The JavaScript in the browser calculates which tree node is currently selected, and then gets the URL from the tree node and sends the information through XMLHttpRequest to the server. The server converts this information into a breadcrumb component consisting of multiple Woodstock hyperlinks. After the code that displays the component returns to the browser, JavaScript updates the breadcrumb information to the current page.
When new objects are created, we also update the tree nodes with Ajax. The entire tree is never completely refreshed, and it is only partially updated via Ajax. We use dynamic faces to implement Ajax technology, which is part of the JSF Extension project led by Ed Burns (the JSF standard manager).
Infoq Chinese Station: JSF an important advantage is based on the component, the management console has not developed its own component library, about the choice of component library use what advice? How do the forms in the management console scale?
Anissa: As mentioned in answer to question 4th, we use the Woodstock component to develop the console. Woodstock provides a complete set of JSF components that allow developers to create convenient localized applications based on uniform specifications. We have not yet encountered situations where we need to develop our own components. If you have this idea, you can take a look at Ken Paulsen's article about ServerSide, who is the technical director and creator of Jsftemplating. He shows how to use jsftemplating to simplify and accelerate display (Render) development.
Many of our pages use forms to display data, which is also one of the Woodstock components.
Infoq Chinese Station: In the process of using JSF, what are the most difficult problems you have encountered and how to overcome them?
Anissa:bug. They are excellent when the components are working, but it's hard to find out why when you're dealing with a new component that can't work. Fortunately, this does not happen often, because components are reused by many people and many programs, so bugs are found in time. However, if this happens, we will communicate with the component authors, ask questions on the forums or IRC channels, and search for similar problems that other people in Google are experiencing, and the problem is resolved.
Infoq Chinese Station: JSF through and session binding implementation data display, although simple, but the control of data is also difficult. How do you understand this situation?
Anissa: The management console avoids using the session scope as much as possible. Frequent use of sessions can result in a large amount of memory being consumed, or some information left over from previous actions can cause bugs. The management console uses the request as much as possible, as well as pagesession, which allows you to store values along with the page, so long as you are on the same page, the value always exists, but it does not exceed the page's lifetime. We did encounter situations where data must exist across pages, either by passing data between pages, or by using sessions in rare cases.
Infoq Chinese Station: What advice do you have for improving the performance of JSF applications?
ANISSA:JSF provides a number of features. However, functionality is valuable only when it is needed. Whether you should use JSF more versatile depends on the requirements of your application. If you want to learn more about features to determine if they are helpful for your application, I recommend you read a good book and ask questions at the JSF forum. You may also consider joining the JSF IRC channel on the irc.freenode.net. This is a good place to listen to other people's questions and get answers from experts. If you are using jsftemplating or just want to know more, #jsftemplating也是一个不错的去处.
Note: Thanks to Sun China Research Institute Kingjian, INFOQ Chinese station Java Community Editor Chacholin to provide intelligent support! This interview is in English, translated by Trikon, Zhang Kai revisers.