OpenSubsystems

Business Components for Java Applications

Open Core

Tutorial

Documentation
Last modified

$Author: bastafidli $
$Date: 2007/03/11 06:30:45 $
$Revision: 1.18 $
$RCSfile: tutorial_overview.html,v $

Overview

Open Core makes development of Java applications faster and simpler and improves their maintainability and portability. This tutorial will walk you through a design and development of an entire application to prove it. It will focus mainly on demonstration of different aspects of Open Core functionality rather than an eye candy. After completing this tutorial you should have a good understanding how Open Core makes development of Java applications easier. If you are impatient you may skip straight to the summary to find out about the benefits of Open Core and browse through the source code for this tutorial.

OpenChronicle

Blogging has gained huge popularity in recent years with websites such as Blogger, WordPress, LiveJournal and MySpace. But how difficult is it to create a blogging software? Let's explore this idea and create a simple blogging application that can be run locally on a laptop or home desktop or made available on the Internet or intranet from a company server. The application will provide the following functionality:

  • Ability to create multiple blogs.
  • Ability to create multiple entries for a blog.
  • Ability to easily display picture for each entry in a blog.
  • Simple authentication and authorization ensuring that an anonymous user can see all blogs and entries but cannot change anything and a logged in user can modify any data in the application.
  • Web user interface to allow blogging from any browser or device with the Internet access.
  • This dynamic web application should look like a set of static pages so that it can be easily saved and distributed either over the Internet or on a CD or a DVD.
  • Ability to deploy this application using any of the supported databases and either as a simple web application using POJO model or using any of the supported J2EE application servers as an EJB based application.

To make our application look more professional ;-), lets give it a name. We will call it OpenChronicle because it will be used to chronicle events and it's source code is freely available. The blogs in it will be called chronicles. The user interface will be quite simple. The default page will show list of all available chronicles. There user can click on chronicle's title to see it's entries. For each entry, user can click on it's title to display just this entry on a separate page to allow easily link to it. Each page will provide link to the login page if the user is not logged in or to the logout page once the user logs in. Once the user is logged in, the default page will allow him or her to create new chronicles, the page displaying one chronicle will allow to modify or delete this chronicle or add new entries to it and the page displaying single entry will allow to modify or delete this entry.

Highlighted blocks such as this one will on the following pages provide insight to Open Core classes you may find useful for implementation of your applications. Reading these is not required to understand the design and implementation of the sample application so you can skip them if you wish so.

View source - this image will lead you to the source code for the class or file the tutorial will be discussing.

Getting started

You can download the source code, libraries to reuse in other projects and the ready-to-use application from the download section. If you want to look at the source code or build the application from scratch you will need both the src and the bin packages. If you just want to run the finished application, you will just need the app package.

The rest of the tutorial will walk you through many of the source files so it might be a good idea to become familiar with them. The project directory structure and build follows the default structure described in the Quick Start guide and the Build Process documentation with a single exception. All the source files for this section of the tutorial are placed in subdirectory

   OpenChronicle/v1
               

Using Open Core is just the first step in the process of understanding and using OpenSubsystems. Step v1 focuses solely on Open Core. Next steps will look at other aspects of OpenSubsystems.

Build process

Lets get started and setup our project. If you are new to Java development, you may follow the developer documentation to setup your environment. It is very easy to build projects developed using Open Core. Open Core provides template Ant build file template-build.xml View source. This file can be used to easily create new project build files by simply copying it and renaming it to match the project name. That's how we have created our build-blog.xml View source. Open Core provides many convenient build targets in reusable file build-common.xml View source. Since our project follows the default structure and guidelines, we can reuse the common targets and our build file therefore consist of only few lines, that specify the name of the project, version, test suite and what external libraries it depends on (in our case it is just Open Core).

   <project name="blog v1" basedir="." default="help">
   
      <!-- Load default build properties -->
      <property file="build.properties"/>
      
      <!-- Load locations of external projects -->
      <property file="external.properties"/>
   
      <!-- Project name -->
      <property name="projectname" value="blog"/> 
      <property name="projectdisplayname" value="OpenChronicle v1"/> 
      <property name="projectversion" value="${blog_version}"/> 
      <property name="projecttestsuite" value="org.opensubsystems.blog.BlogTests"/> 
      <property name="includeconfig" value="true"/> 
   
      <available file="${build_files_home}/build-common.xml" 
                 property="build.files" value="${build_files_home}"/>
      <available file="${external_projects_home}/build/build-common.xml" 
                 property="build.files" value="${external_projects_home}/build"/>
   
      <!--
         This project doesn't have any special source code requirements, if it has
         some in the future define following target
         <target name="preparesource" depends="common.preparesource"> 
           Prepare here any special source code which is not prepared by the common
         </target>
      -->
      
      <target name="preparelibs" depends="init"> 
         <ant antfile="${build.files}/build-external.xml" 
              target="installcore"/>
      </target>
   
      <target name="cleanall" depends="init,clean" 
              description="Clean everything generated by this build and dependent projects.">
         <!-- TODO: Figure out what else do we need to cleanup -->
      </target>
   
      <import file="${build.files}/build-common.xml"/>
      
   </project>
               

The build.properties View source file contains settings that control the build, mainly version numbers, locations of different project components and settings specifying what to build and what not (e.g. generate EJB components, precompile JSP pages, etc.). The external.properties View source file contains locations of all external libraries this project depends on. In our case these are only Open Core libraries, since Open Core comes with all the other external libraries it depends on. File filter.properties View source contains any strings that needs to be replaced in the source code or documentation during build. Finally, file javaheader.txt View source is used by Checkstyle to verify that all the files contains necessary documentation about project, copyright, license, etc.

With all the infrastructure in place and ability to build our project, we are ready to start working on the code itself.

Next: Designing the data model