![]() |
|
URL of the article:
The Enterprise Java Open Source Architecture Template
A Beginners' Way to J2EE Application Development
by Blasius Lofi Dewanto
The Enterprise Java Open Source Architecture (EJOSA) Template was built to help computer science students, at the University of Munster, develop J2EE projects with a low learning curve. With little to no experience in J2EE, and a modest experience in Java, students were able to use the EJOSA template to create robust and production-ready J2EE projects. In the first part of this article, EJOSA architect Lofi Dewanto takes a close look at this magic template -- Enhydra (Web container), JOnAS (EJB container) and HypersonicSQL (data container for development) or Firebird DBMS (data container for production).
The bane of many a J2EE novice has been the complexity associated with developing J2EE applications, using servlets and EJBs. Many commercial J2EE products that tried to address this problem failed either because their products were cluttered with features that overwhelmed J2EE beginners or simply because they failed to contribute to the explanation of the underlying development process itself. This article presents a solution for J2EE beginners who wish to overcome the complexity of J2EE application development by using Open Source Software (OSS). Complexity of J2EE Application Development Before we delve into the EJOSA solution, it is important to take a closer look at what makes the development of J2EE applications so complicated and inconvenient. Here are some points to consider:
The multi-tier architecture, shown in Fig.1, is the basic architecture for J2EE. It illustrates the logical separation of the application into presentation, business, and data layers to improve its reusability, scalability, and ease of control. The infrastructure of the multi-tier architecture comprises of the operating system, the network, distributed protocols like Internet Inter-ORB Protocol (IIOP) or Remote Method Invocation (RMI), and the Java Virtual Machine as the main part. At the development stage there is a need for both a development and a communication platform (if more than one developer is deployed on the project). The development platform consists of an IDE and a Concurrent Versioning System (CVS). Forums, mailing lists, Wiki and chat rooms represent the tools for the communication platform. And, during runtime, we need runtime containers like the Web, EJB, and the data container. Before we can begin with the development of a J2EE application, we need to instantiate this architecture. I have instantiated the J2EE architecture with Open Source products to create the Enterprise Java Open Source Architecture (EJOSA). EJOSA implies Enhydra and JOnAS Application, because it uses Enhydra and JOnAS as the main Open Source products. It also uses HypersonicSQL (data container for development) and Firebird DBMS (data container for production). See Fig. 1: ![]() Fig. 1: Multi-tier Architecture for J2EE and EJOSA (simplified) Further, to ease the J2EE application development, I designed a template based on EJOSA, called the EJOSA Template. Advantages of using the EJOSA Template The EJOSA Template offers the following advantages:
For in-depth information on each of these topics, please refer to the mentioned references; EJOSA Template demonstrates only the most important aspects for developing J2EE applications, to retain the simplicity. Architecture and Development Process using EJOSA Template It is recommended to download and unpack the EJOSA Template into your working directory (see the EJOSA information at the end of this article) before delving into the following indepther. Introduction The directory structure for a J2EE application is one important step to building a reusable template. A good structured directory gives you the general idea quickly. EJOSA Template offers a standardized directory structure. At the top of the structure (see Fig. 2) it gives a J2EE application a name like "ejosa-revo". EJOSA Template separates internal (dev-framework) and external (ext-libs) frameworks or libraries. Although reuse from external libraries is the way of component-based software development, in certain situation it is not possible to find suitable libraries. To avoid such a scenario, EJOSA Template puts all self developed internal libraries centralized in one directory. Due to the instability of the internal libraries it is always wise to separate internal from external libraries. The dev-cartridges directory contains all the MDA cartridges, which EJOSA provides to transform and generate the models into another models or source codes. We shall discuss this directory further, in the Model section, later in the article. Since J2EE applications may consist of one or more components, it is recommended to separate those components into different subdirectories. EJOSA Template defines dev-templates directory for each component, which should be seen as dev-your-own-component or dev-xxx. Replace this directory with your own components directory. To see all the template files that can be used as an example, go to the directory: ejosa-revo/dev-cartridges/cartridges/ejosa-component-structure/src/templates, where you will see all template files that build the structure of one component. For the purposes of this article, the term "component" has to meet following requirements:
![]() Fig. 2: Structure of EJOSA Template and Dependencies between Directories Model The model directory contains the model element of the component. As a standard, Unified Modelling Language (UML) should be used to model the component. You can also check out MDA (Model Driven Architecture), MOF (Meta Object Facility), XMI (XML Metadata Interchange), and JMI (Java Metadata Interchange) to understand the model directory in more detail. The implementation of the model part is based on AndroMDA 3.x. Use PoseidonUML Community Edition to model your component and export the result into an XMI file, which will be read by the AndroMDA tool to generate codes or transform into another models. AndroMDA uses the concept of cartridge to componentize generators and transformers. Fig. 3 shows the development process using AndroMDA and the importance of the cartridge concept within the AndroMDA 3.x architecture. ![]() Fig. 3: Architecture of AndroMDA AndroMDA 3.x delivers built-in cartridges such as EJB 2.x, EJB 2.x-Hibernate, BPM4Struts, WebService, POJO (Plain Old Java Object) cartridges and some experimental cartridges for Data Definition Language (Database DDL) and SpringFramework. I customized some of them to meet the structure of EJOSA Template. You can use the built-in cartridges from AndroMDA 3.x without customizing within EJOSA as well (see ext-libs/readme-external-libs.txt for detailed information on AndroMDA 3.x distribution; for AndroMDA 3.x documentation, click here). All EJOSA cartridges are located in the directory dev-cartridges. To develop your own cartridges you need to understand the idea of metamodels (especially for UML). AndroMDA delivers a Metafacade cartridge, which can be used to develop your own cartridges (Note: use an available cartridge to develop a new cartridge). The process of developing cartridges must be included into the developer's compile-build-run-test cycle iteratively as it is almost impossible to create these cartridges perfectly in the first attempt. EJOSA Template offers the following customized and extended cartridges: EJOSA Template cartridges are categorized into different types: component, model, specification (Application Programming Interface - API) and different layer of implementation like business layer implementation and presentation layer implementation. It is also important to know the standard stereotypes and tagged values from AndroMDA Metafacade UML, as they are needed to mark the model. All cartridges will use the same standard UML profile from the Metafacade UML (see Table 2). To see the most up-to-date stereotypes and tagged values, refer the following files:
This drawback, of not being able to see all the stereotypes and tagged values in one place, needs to be solved in a future version of AndroMDA. Fig. 4 shows all the sources you need to look for, to know the up to-date UML profile (stereotypes and tagged values) of each cartridge. ![]() Fig. 4: Sources for the UML Profile Example Model: I use a very simple example "PiggyBank" (PoseidonUML file: dev-piggybank-swing-enhydra-ejb-hibernate/model/src/piggybank.zuml) to go through the directories in EJOSA Template. Fig. 5 shows a simple use case diagram, activity diagram, and class diagrams that explain the functions and structure of the PiggyBank application. Here are the steps to develop the example:
![]() ![]() ![]() Fig. 5: Model: use case, activity, and class diagrams of PiggyBank In the concept of AndroMDA, it is necessary to mark the model element in the PIM you want to work with, with stereotypes (<
Depending on the cartridge you can transform your model into another one, and generate the source codes automatically. Also, more importantly, everybody in your team (including your business analyst and chief) can understand the functions of your application easily (thanks to the diagrams) and be updated regularly, since you will always have to change the model to modify your component implementation. Reverse Engineering Out, Forward Engineering In! In the next part of this series, we will move further into the workings of EJOSA Template and look at the specification directory, which is the most important part of EJOSA Template; the business layer, where you implement the specification with available Java technologies; the presentation layer that represents the view of the business logics; and the roadmap for EJOSA Template. Blasius Lofi Dewanto is a Professor Assistant at the Institute for Business Informatics and Controlling, at the University of Münster, Germany. Reach him via e-mail: dewanto@uni-muenster.de References [Ref. 1] G. T. Heineman and W. T. Council, Component-Based Software Engineering - Putting the Pieces Together, Addison-Wesley, 2001. [Ref. 2] J. Cheesman, and J. Daniels, UML Components: A Simple Process for Specifying Component-Based Software, Addison-Wesley, 2001. [Ref. 3] P. Allen, Realizing e-Business with Components, Addison-Wesley, 2001. [Ref. 4] R. Sharp, Component Oriented Software: Java Perspectives, http://www.softwarereality.com/programming/component_oriented.jsp. [Ref. 5] F. Marinescu, EJB Design Patterns, Advance Patterns, Processes and Idioms, John Wiley & Sons Inc., 2002. [Ref. 6] The Middleware Company, J2EE Best Practices, http://www.theserverside.com/resources/article.jsp?l=TMCBestPractices. [Ref. 7] E. Cecchet, J. Marguerite and W. Zwaenepoel, Performance and Scalability of EJB Applications, http://rubis.objectweb.org/download/perf_scalability_ejb.pdf. [Ref. 8] D. H. Young, XMLC vs. JSP, http://www.theserverside.com/resources/article.jsp?l=XMLCvsJSP. [Ref. 9] Kleppe, A., Warmer, J., Bast, W., MDA Explained, Addison-Wesley, 2003. [Ref. 10] Frankel, D. S., Model Driven Architecture, Wiley, 2003 EJOSA Template Links Project site: http://ejosa.sourceforge.net/ Download Revolutions 2.2: http://sourceforge.net/project/showfiles.php?group_id=69075&package_id=83592&release_id=272948 Documentation PDF Revolutions 2.2: http://prdownloads.sourceforge.net/ejosa/ejosa-revo2.2-doc.pdf?download HOW-TO Installation and Release Document Revolutions 2.2: http://sourceforge.net/project/shownotes.php?release_id=272948 Open Source Products Links OpenUSS (Open University Support System) eLearning Platform: http://www.openuss.org/ Wafer Comparison of presentation layers: http://www.waferproject.org/ 1. Development SourceForge: http://www.sourceforge.net/ NetBeans IDE: http://www.netbeans.org/ Eclipse IDE http://www.eclipse.org/ ArgoUML UML diagrams: http://www.argouml.org/ AndroMDA MDA development: http://www.andromda.org/ Jalopy Source Code Formatter for Ant: http://sourceforge.net/projects/jalopy JUnit unit testing: http://www.junit.org/ JUnitEE unit testing for J2EE: http://www.junitee.org/ Grinder stress testing: http://sourceforge.net/projects/grinder XDoclet Attribute Oriented Programming: http://sourceforge.net/projects/xdoclet AspectJ Aspect Oriented Programming: http://www.aspectj.org/ MTL MDA development: http://modelware.inria.fr/rubrique.php3?id_rubrique=8 2. Development and Runtime ObjectWeb Enhydra Servlet container: http://www.enhydra.org/ ObjectWeb JOnAS EJB container: http://www.objectweb.org/jonas HSQLDB database container: http://sourceforge.net/projects/hsqldb Jakarta Ant Build and Execution library: http://ant.apache.org/ Jakarta ORO Regular Expressions: http://jakarta.apache.org/oro/index.html Jakarta Lucene Search Engine: http://jakarta.apache.org/lucene/index.html JDom for building XML files and data: http://www.jdom.org/ OSCore OpenSymphony J2EE libraries: http://www.opensymphony.com/ Quartz Scheduler: http://sourceforge.net/projects/quartz SkinLF Swing Skin Look and Feel: http://www.l2fprod.com/ Free, yet not Open Source, Products mentioned in this Article PoseidonUML Community Edition: http://www.gentleware.com/ |
||
|