Modeling Servlets in UML

The GenericServlet class is usually modeled as a standard Java class with the <<Generic_Servlet>> stereotype applied. The presence of the stereotype allows for the servlet to be represented in a compact form and still be easily distinguished as a generic servlet without the need to show the inheritance tree on the same diagram. A generic servlet can include any of the life cycle methods or the convenience method discussed earlier.

A more expanded view of the servlet class showing the inheritance from the GenericServlet class can also be used. In most cases, though, the more compact stereotyped class view is sufficient. The compact and expanded representations of the servlet are shown in Figure 10-5.

Figure 10-5. Compact and full representation of a generic servlet


If the servlet implements the SingleThreadModel interface, which controls serialization of the service method, the servlet can be shown with the interface to highlight this aspect. Optionally, the servlet can be tagged with { Single ThreadServlet=True} instead to clearly identify this on the diagram in a somewhat more compact format.

An example of a servlet that implements the SingleThreadModel is shown in Figure 10-6.

Figure 10-6. Servlet supporting the SingleThreadModel


The HttpServlet class is modeled similarly to GenericServlet, but with the <<Http_Servlet>> stereotype applied. It can also include the life cycle methods, the convenience method, and any of the HTTP request handlers previously discussed.

The SingleThreadModel details as well as the tagged value for SingleThreadServlet apply in the HttpServlet class exactly the same way as they did for GenericServlet. As stated earlier, you should not attempt to serialize any of the servlet methods other than by implementing this interface. This interface does not introduce any new methods.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.138.123.208