Java 2EE and XML Development

Скачать в pdf «Java 2EE and XML Development»

Figure 6.5 depicts these components in a class diagram using the Universal Modeling Language (UML). If you are unfamiliar with UML notation, there is a legend next to the ComponentLocator class that explains the composition of the diagram.

Class Name

ctx : Context



updateBugList (String) : org.jdom.document






ctx : Context    ◄-

cl : ComponentLocator

ComponentLocator() getInstance() : ComponentLocator getBeanHome(String) : EJBHome getWebService(String) : EJBObject


Attribute Name: Type

Method Name (Parameters) : Return Type

Figure 6.5 Case study design architecture: BugAccessorBean and ComponentLocator

The ApplicationMenu component

The ApplicationMenu is a class that is responsible for building the initial menu for our system. The information necessary to build the menu is stored in a file named menu.xml. This was designed intentionally, so that new branches and functions can be added to the system with relative ease. Each time a user request is received, it is impractical to reload this information from a file. This will undoubtedly cause performance problems. In order to alleviate this problem, we employ the Singleton pattern once again and load the data into our ApplicationMenu class. Once we have initially loaded the menu, the getMenu method merely returns the JDOM containing the menu information to the caller. This is a caching method often used when the data is accessed frequently and is not frequently modified. The reason that we have chosen this architecture over using a bean is that the remote calls necessary to look up a bean require too much overhead. One instance of this class in each JVM serves our needs. In a different situation in which our class performed more intense logic, we would reevaluate our design.

Скачать в pdf «Java 2EE and XML Development»