Getting Started with Application Development - aceoperator/mw Wiki

Once you have installed the Open-Source Middleware using the instructions in the Installation Guide, you are now ready to start developing your Middleware application. The Open-Source Middleware comes with starters for developing various types of features like database access, report generation, etc. and you can easily add anything you need at the top of it. We are continuing to provide howto/recipes wiki pages that describe how to develop specific feature (example: database access) but this page covers the general concepts.

The software uses the Spring Framework and Maven heavily. You may want to read up on Spring Framework 3.1.x and Maven 3.x and get familiar with them before getting started.

Project Structure

When you open the top-level directory of the Open-Source Middleware, you will see that it is a multilevel Maven project with three child projects:

  1. Middleware Core: Contains a set of Java classes and Spring configurations for the core features. This is a class library containing the core business logic that can be used by a services layer code to provide the business logic for functionality like REST services, system integration, etc. The core currently includes classes for basic authentication/authorization using a database realm, report generation, email support, security and caching support.
  2. Middleware Services: The services layer is a thin layer that uses the core library to provide services like REST web services, integration services (uses Apache Camel EIP framework), interface for communicating with a Business Process Management Engine, etc. In short, this is a thin layer at the top of the core layer to provide remoting, integration and other features. The services layer is deployed as a web application and comes with authentication and authorization infrastructure.
  3. Middleware Assembly: This sub-project builds the binary distribution for deployment.

Adding New Features

The Open-Source Middleware is provided as a source distribution. You may checkout the code either one time and develop your application without ever pulling updates from the Open-Source Middleware repository or periodically pull new features, upgrades and bug-fixes from the repository. If you choose the latter, you have to make sure that you are not modifying the existing files as far as possible to avoid difficult merge issues. Here are a few tips to avoid merge issues.

  1. Create your own Java package for developing your own features. For example, you are creating a core business logic for accessing your customers' activities from the database. Create two new packages - com.yourorg.yourproject.business containing the interfaces for the business logic and com.yourorg.yourproject.dao for the interfaces that abstracts the database access. We suggest that you create separate packages for the implementation classes implementing the above interfaces. You may have a business logic interface called com.yourorg.yourproject.business.CustomerActivity and the corresponding implementation class com.yourorg.yourproject.business.impl.CustomerActivityImpl (note the new impl package). For the DAO, you may have an interface called com.yourorg.yourproject.dao.CustomerActivityDao that defines all the methods that you want your DAO layer to implement.
  2. Once you created all the interfaces and classes, you will have to add the Spring configuration defining the beans that you created and inject the necessary dependencies. For the core features, add the Spring bean configuration in the file mw-core/src/main/resources/META-INF/MwCoreSpringBeans.xml file.
  3. If your code requires new libraries, not included in the dependency list, add them to the mw-core/pom.xml file.
  4. Make sure to create junit tests for new features you develop. All tests must be located under the src/test/java directory and all configuration and other resources must be in the src/test/resources following the usual Maven conventions. Only tests that are located in packages that end with .unit are run. Other packages are meant for classes to support the tests. You can create mock objects using Mockito if you need them. You can model your test classes using one of the test classes that is part of the Open-Source Middleware. The Cobertura code coverage tool is already included with the Maven configuration. When you run the reporting targets, you can see the code coverage of the tests.

More to come...